Very often we have the requirement of displaying the first column in a table to be the row number or row index. The below snippet shows how to do it in a dataTable in richfaces. rowKeyVar attribute is the candidate here and as the index starts from zero we mention #{rowKey+1} to display the row number/index/count.
<rich:dataTable rowKeyVar="rowKey" id="optiontbl"
value="#{mcqaction.files}" var="qopt">
<rich:column>
<f:facet name="header">No.</f:facet>
<h:outputText value="#{rowKey+1}" />
</rich:column>
..........
display other columns here
..........
</rich:dataTable>
This displays data as below.

