Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

row counter for html table row

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.

like image 625
crazyTechie Avatar asked Dec 30 '09 10:12

crazyTechie


Video Answer


2 Answers

As of Facelets 2.0, this is now possible using the varStatus.

<ui:repeat varStatus="status" var="user" value="#{collection}">
     #{status.index}
</ui:repeat>
like image 183
ustun Avatar answered Sep 17 '22 13:09

ustun


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>
like image 23
Bozho Avatar answered Sep 19 '22 13:09

Bozho