SimpleSelection with ExtendedDatTable
skidvd May 2, 2009 6:40 PMHello,
I'm having difficulties getting the correct results from the combination of the SimpleSelection when used with the ExtendedDataTable. I get the correct results as long as the table has NOT been sorted by any columns (i.e. original order). However, as soon as I sort the table by a column, the results produced are incorrect (single sortMode).
The only examples I have found seem to be used with a ScrollableDataTable. These examples show that the getSelection().getKeys() method returns Iterator. Yet in the case of the ExtendedDataTable, it just returns and Iterator - which is effectively just Integers.
I also thought of calculating the the correct index based on the SortOrder; but, even though I am monitoring the SortOrder, the SortOrder.getFields() method always returns null.
Here is my table definition....
<rich:extendedDataTable id="discoveryListTable" value="#{discoveryLists}" var="discoveryList" eventsQueue="discoveryListEvents" onRowMouseOver="this.style.backgroundColor='#FFFFCC'" onRowMouseOut="this.style.backgroundColor='#{a4jSkin.rowBackgroundColor}'" rowClasses="lightRow, lightRow, lightRow, darkRow, darkRow, darkRow" selectedClass="selectedRow" height="370px" width="100%" rows="15" sortMode="single" sortOrder="#{discoveryListController.sortOrder}" tableState="#{discoveryListController.tableState}" selectionMode="multi" selection="#{discoveryListController.selection}" status="mainStatus"> <a4j:support event="onselectionchange" ajaxSingle="true" action="#{discoveryListController.onSelectionChange()}" reRender="clearSelectionButton,editButton,deleteButton,discoveryListMsgs" limitToList="true"/> ..... </rich:discoveryList>
Finally, and most importantly, due to some complexities with the way Seam conversations are used in this application, I CANNOT make use of the RichFaces ExtendedDataTable binding attribute to gain access to the table and consequently 'determine' the correct row via a getTable().setRowKey( key ) style operation.
Finally, I have also tried to use the Seam @DataModelSelection without success. Unfortunately, it always returns the last value in the List - regardless of sort order of table. I had thought this would work, but apparently not, or I'm missing something else?
@DataModel protected ArrayList<DiscoveryList> discoveryLists = null; @DataModelSelection @In( required=false ) @Out( required=false ) protected DiscoveryList selectedDiscoveryList = null;
Furthermore, this mechanism seems to be incomplete in a multiple selection table? It would seem that you would need to 'build-up' a list of multiple selections as the user makes them?
I'm really at a loss. If I could use the binding attribute, I can make things work properly. However, as the app uses multiple ExtendedDataTables within a conversation, this is not possible - binding will cause columns and other table info to 'cross-pollinate' between the tables when using the EVENT scope controller required for binding attributes in a Seam application.
The SimpleSelection method appears to be the only approach left/best approach in this environment. However, it does not produce the correct results when the table is sorted?
Can anyone help me out with some insight, ideas or point me to some ExtendedDataTable specific examples WITHOUT binding for tracking and accessing multi selection in a backing bean component?
Thank you!