Showing row index during data iteration in Seam RichFaces


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.


 
 
 
 
Comments:

Post a Comment:
  • HTML Syntax: Allowed
 

« January 2009
SunMonTueWedThuFriSat
    
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
       
Today

Valid XHTML or CSS?

[This is a Roller site]
 
© Karthik