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?
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.
Joined: Mar 14, 2011
Thank you for the enlightenment. I have lots to learn.