Iterating selected rows in an ADF Faces table
- by Frank Nimphius
In OTN Harvest May 2012; http://www.oracle.com/technetwork/developer-tools/adf/learnmore/may2012-otn-harvest-1652358.pdf I wrote about "Common mistake when iterating <af:table> rows". In this entry I showed code to access the row associated with a selected table row from the binding layer to avoid the problem of having to programmatically change the selected table row.
As it turns out, my solution only worked fro selected table rows that are in the current iterator query range. So here's a solution that works for all ranges
public String onButtonPress() {
RowKeySet rks = table.getSelectedRowKeys();
Iterator it = rks.iterator();
while (it.hasNext()) {
List selectedRowKeyPath = (List)it.next();
//table is the JSF component reference created using the table's binding
//property
Row row = ((JUCtrlHierNodeBinding)table.getRowData(selectedRowKeyPath)).getRow();
System.out.println("Print Test: " + row.getAttribute(1));
}
return null;
}