Displaying row index while looping using ui:repeat in JSF
It was introduced in Facelets 2.x. Given the fact that it doesn't work, you're using Facelets 1.x.
Facelets 2.x is not standalone available. It is embedded in JSF 2.x. If you can, upgrade to JSF 2.x. If you can't, then you've either to wrap the model in a custom model which holds the index as well, or to grab <c:forEach>
instead if your view markup allows it (it's a view build time tag, not a view render time tag), or to grab Tomahawk's <t:dataList>
instead which has a rowIndexVar
attribute for this purpose.
Update as per the comments, you turn out to be using RichFaces. In that case, you can also use the <rich:dataList>
or <a4j:repeat>
which offers both a rowKeyVar
attribute:
<a4j:repeat value="#{bean.items}" var="item" rowKeyVar="index">
<p>#{index} #{item}</p>
</a4j:repeat>
Punter Vicky
Updated on June 04, 2022Comments
-
Punter Vicky almost 2 years
I am using ui:repeat tag and I have set varstatus="current".I try to display the row index using the below command, but nothing is getting displayed.
<h:outputText value="#{current.index}"/>
I would like to display the row index.