This is a useful handy code to get the selected rows for the table.
What it does:
- Get handle to the table using the JSFUtils find component method with the table id passed as a parameter
- Get the selectedRowKeys for the table
- Iterate through the rowkeys
- Get the rowkey from the iterator
- Add the rowkeys into a list
- return the list to the caller
This method takes the table id as the parameter
private List getSelectedList(String tableName) { RichTable rt = (RichTable)JSFUtils.findComponentInRoot(tableName); RowKeySet keySet = rt.getSelectedRowKeys(); Iterator iter = keySet.iterator(); iter = keySet.iterator(); List list = new ArrayList(); while (iter.hasNext()) { list.add(iter.next()); } return list; }
Usage:
This method is used to check if any rows are selected for the particular table. The method returns the rowkeys of the rows selected if there are any rows selected for the table