I have a JSF woodstock table with checkboxes. When a row is selected I want to do some processing with those items. I managed to get a selection of RowKey objects but can't find out how to get the original objects I put in back. The table is populated by an ObjectListDataProvider.

+1  A: 

Always nice to be able to answer you own questions. I managed to solve it by casting the table's data provider to ObjectListDataProvider and use the method 'getObject' to get my original object back.


Check if this is useful.


Hi, could you add your code so that I solve the same problem? In my case I try to get the RowKey but its empty, thanks


So I stumbled across this and was hoping to find how to actually do the selecting and get the row information. I eventually figured it out and I thought others might benefit from how I did it.

I added a RadioButton to a table column in the JSP and added a valueChangeListener

<ui:radioButton id="radioButton1" name="radioButton-group1" valueChangeListener="#{MyBeanPage.radioButton1_processValueChange}" />

In my Java code I created the valueChangeListener function and stored the current row information.

public void radioButton1_processValueChange(ValueChangeEvent event) {
  TableRowDataProvider trdp = (TableRowDataProvider)getValue("#{currentRow}");
  setCurrentRowKey(trdp.getTableRow());  //Sets an instance variable for the RowKey

Now if you have any buttons that want to manipulate the data in the selected row you can do this to get the object data. Jasper mentioned this above.

/*getObjectListDataProviderImpl() returns the implementation of 
 *ObjectListDataProvider for your dynamic data.

You might be able to use something like selectedValue attribute for radio button in conjunction with something else instead of doing valueChangeListener and avoid having to do a valueChange function but this worked so I didn't care to figure out another way.