File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSF and the fly likes datatable row id Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "datatable row id" Watch "datatable row id" New topic
Author

datatable row id

bruce truong
Greenhorn

Joined: Mar 14, 2011
Posts: 11
Hello all,

I googled all day long but cannot find how to add the row id to a JSF datatable. Row id is made up of user's ID. I would like to basically create <tr id=123456>. Can someone point me to the right direction?

Thanks
btran
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15629
    
  15

The JSF/xml "id" attribute isn't really a good place to store data. It's not intended for that purpose. Among other things, you might have noticed that it's not legal to use EL to substitute in an id value.

If it's really required to place a key value such as userid in a row in a dataTable and you don't want it visible, you can put it in a hidden text field. But chances are that you are really just trying to know which row was selected when you click on a button or link in the dataTable.

If that's the case, you're over-complicating things. An action method fired by a control in a dataTable can simply call getRowData() on the backing datamodel object to get the row object that backs that particular row. Or use getRowIndex() to get the index of the row.

Because of this mechanism, you don't actually even need to put the record ID out on the webpage at all unless you want to. When the action is fired, any user changes on the web form will have been pushed into the datamodel's row object, and you'll know which row it was, so it's then a trivial matter to scoop up that data and write it out to the database or do whatever else you want to do with it.


Customer surveys are for companies who didn't pay proper attention to begin with.
bruce truong
Greenhorn

Joined: Mar 14, 2011
Posts: 11
Thank you for the enlightenment. I have lots to learn.

btran
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: datatable row id
 
Similar Threads
Specifying row classes in dataTables
Create row index in dataTable
JSF,marked a selected row of datatable
Problem with selecting checkboxes in subTable
Accessing a dataTable's row in javascript