I'm using the repeat
tag of JSF 2.0 to loop through a list of objects and display some of their properties. I want to use the varStatus
attribute of repeat
so that I can access the loop index, the number of the last list item, and to tell whether the end of the list has been reached (so the spacer won't be displayed). I thought this would work:
<ui:repeat var="anObject" varStatus="repeatStatus" value="#{objectList}">
<h:panelGroup>
<h:outputText value="Item #{repeatStatus.index + 1} of #{repeatStatus.end}" />
<h:outputText value="#{anObject.text}" />
</h:panelGroup>
<h:outputText value=" " rendered="#{false == repeatStatus.last}" />
</ui:repeat>
However, it never displays anything for repeatStatus.end
. The index
and last
properties work well.
Instead of repeatStatus.end
, I tried using objectList.size()
, but that worked for only the first item in the list.
How can I display the number of items in the list as part of the "Item x of y" text?