-
1. Re: Getting selected item ids from a datatable
danielc.roth Feb 25, 2008 5:43 PM (in response to boki)In the richfaces scrollable data table you may click-select rows (even multiple) and bind a selection object to your backing bean. I find that very neat...
there is a nice example on their live demo page http://livedemo.exadel.com/richfaces-demo/richfaces/scrollableDataTable.jsf?c=scrollableDataTable
-
2. Re: Getting selected item ids from a datatable
boki Feb 25, 2008 6:00 PM (in response to boki)Thanks for the reply. I wonder though if takeSelection method manipulates UI Components directly or does it in a different way. Any thoughts?
-
3. Re: Getting selected item ids from a datatable
danielc.roth Feb 25, 2008 8:32 PM (in response to boki)It sort of takes them directly. It was some days ago I read that code but it workes something like this:
selection="#{dataTableScrollerBean.selection}"
gets/sets a Selection object. It contains a map with key/object to the rows that are selected. Hence, the
takeSelection
code iterates over this Selection object and just creates another list with selected items. Something like (psuedocode, all names made up):public List<RowItems> takeSelection() { Map<Integer,RowItem> allItems = getItems(); List<RowItems> selectedItems = new LinkedList<RowItems>(); for(MapItem item: selection) { selectedItems.add(allItems.get(item.getKey())); } return selectedItems; }