【问题标题】:varstatus attribute in ui:repeat in jsf 1.2ui 中的 varstatus 属性:jsf 1.2 中的重复
【发布时间】:2012-05-10 21:40:12
【问题描述】:

如何在JSF 1.2 的ui:repeat 中实现varstatus 属性的功能?如果不能在 1.2 版本中使用,有哪些可用选项来获取 arraylist 的第一项和最后一项?

请提供您的想法来帮助我。

【问题讨论】:

    标签: jsf facelets jsf-1.2 uirepeat


    【解决方案1】:

    改用 JSTL 的 <c:forEach>

    <c:forEach items="#{bean.items}" var="item" varStatus="loop">
        <c:if test="#{loop.first}">First</c:if>
        <h:outputText value="#{item}" />
        <c:if test="#{loop.last}">Last</c:if>
    </c:forEach>
    

    或者改用 Tomahawk 的 &lt;t:dataList&gt;

    <t:dataList value="#{bean.items}" var="item" rowCountVar="count" rowIndexVar="index">
        <h:outputText value="First" rendered="#{index == 0}" />
        <h:outputText value="#{item}" />
        <h:outputText value="Last" rendered="#{index + 1 == count}" />
    </t:dataList>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-02-13
      • 2014-03-10
      • 2015-11-16
      • 2013-05-07
      • 2012-07-12
      • 1970-01-01
      • 2013-04-03
      相关资源
      最近更新 更多