permaculture playing cards*
The moose likes JSF and the fly likes Row Index in RichFaces Data Table Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "Row Index in RichFaces Data Table" Watch "Row Index in RichFaces Data Table" New topic

Row Index in RichFaces Data Table

Soumya Saha
Ranch Hand

Joined: Apr 14, 2006
Posts: 64

I have been really struggling to get the row index from the richFaces Data Table in my java script function.

I tried the this object, rowKeyVar attribute, dataTable.rowIndex but nothing seems to work. I binded the data table to an htmldatatable, but still returns 1 only.

I am attaching the code for the binding attribute:

<h:dataTable binding="#{myBean.dataTable}">
<f:facet name="header">
<hutputText value="Row #" />
<hutputText value="#{myBean.dataTable.rowIndex + 1}" />


Any help or any direction will be highly appreciated.

sujit suncert

Joined: Nov 04, 2008
Posts: 6
Try like this.

Create ListDataModel from list that you are displaying in rich:datatable.
new ListDataModel(java.util.List list);
To your rich:datatable values attribute set this listdatamodel.

Now try row.rowIndex.Should work for sure. Let me know if it does not.

-sujit(Never lose hope)
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 60752

"sujit sun certified", please check your private messages for an important administrative matter.

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Soumya Saha
Ranch Hand

Joined: Apr 14, 2006
Posts: 64

I got it to work with rowKeyVar. I can pass that value in my JavaScript Function and it returns me the correct row value.

Thanks everybody and long live RichFaces

With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
subject: Row Index in RichFaces Data Table
Similar Threads
Row Index in RichFaces Data Table -- JBOSS-RICHFACES
Input row select on data table does not get called
nested h:datatable question
problem with datatable binding attribute
How to use datatable with no records in a list