2012-05-01 35 views
3

如何在ui中實現varstatus屬性的功能:在JSF 1.2中重複執行?如果它不能在1.2版本中使用,有什麼可用選項來獲取數組列表的第一個和最後一個項目?ui中的varstatus屬性:在jsf 1.2中重複

請通過提供您的想法來幫助我。

回答

8

改爲使用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> 

或者使用戰斧的<t:dataList>代替。

<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>