I have HTML table in JSF web application. I am generating rows dynamically using <ui:repeat>
. I want a counter for each row. How can I get this? Any help?
Ssimilar to rowKeyVar in rich faces dataTable.
As of Facelets 2.0, this is now possible using the varStatus
.
<ui:repeat varStatus="status" var="user" value="#{collection}">
#{status.index}
</ui:repeat>
Since you are using richfaces, you can do it with its iteration tag (<a4j:repeat>
), which is a bit more appropriate than using <c:forEach>
, and which is like an extension to <ui:repeat>
<table>
<a4j:repeat value="#{bean.list}" var="item" rowKeyVar="idx">
<tr>
<td><h:outputText value="#{idx + 1}" /></td>
<td><h:outputText value="#{item.someProperty}" /></td>
<td><h:outputText value="#{item.otherProperty}" /></td>
</tr>
</a4j:repeat>
</table>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With