使用<f:convertDateTime>和<h:commandLink>

3

我看到了BalusC提供的这个例子:

<h:outputText value="#{bean.calendar.time}">
    <f:convertDateTime type="both" dateStyle="long" />
</h:outputText>

如何使用 <h:commandLink> 进行操作?

我尝试过:

<h:commandLink value="#{question.creationDate.time}"
    action="#{managerBean.searchQuestion()}">
  <f:convertDateTime type="both" dateStyle="short" />
  <f:setPropertyActionListener target="#{managerBean.questionID}"
    value="#{question.ID}" />
</h:commandLink>
1个回答

9
<h:outputText>放在<h:commandLink>里面。
<h:commandLink action="#{managerBean.searchQuestion}">
    <h:outputText value="#{question.creationDate.time}">
        <f:convertDateTime type="both" dateStyle="short" />
    </h:outputText>
    <f:setPropertyActionListener target="#{managerBean.questionID}" value="#{question.ID}" />
</h:commandLink>

完美运作!我没想到我可以在<h:commandLink>中使用<h:outputText>。 - alexander

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接