changing extended data table selection
ammaletu Aug 18, 2009 10:37 AMHi!
I'm using an ExtendedDataTable on my page and have problems working with the selection. On the tree component, I can bind the selection to the backing bean and manipulate it there, e.g. select a newly inserted tree node before rerendering the tree. That works fine. If I try to do the same with my table, it seems I need the table component to make this work. Simply changing the SimpleSelection instance does not have the desired effect.
For the record, I'm using RichFaces 3.3.1, MyFaces 1.2.5 and Facelets 1.1.14, with JDK 1.6 and Tomcat 6.0.18.
My backend method is this:
/** * Sets the table selection without the direct click on the table by the * user. * * @param argRowIndex The row index to set, counted from 0. Use -1 to remove * the current selection. * @param argTable The table in which to set the row. */ private void setTableSelection(int argRowIndex, UIExtendedDataTable argTable) { SimpleRowKey newRowKey = null; SimpleSelection newSelection = null; // set the table selection if (argRowIndex >= 0) { newRowKey = new SimpleRowKey(argRowIndex); if (argTable != null) { argTable.setActiveRowKey(newRowKey); } newSelection = new SimpleSelection(); newSelection.addKey(newRowKey); } else { newSelection = new SimpleSelection(); } setTableSelection(newSelection); // makes the selection visible for the user if (argTable != null) { argTable.setSelection(newSelection); } }
This would probably work if I had the table available, but unfortunately I don't. I can't bind the table to a property and get it from there, because the table is not serializable, but Spring Web Flow insists on serializing the stuff between calls. And I don't cal this method from a method which gets an event, so that I have any component.
I guess what I'm asking is: Is there either a way to get the table component in my method instead of having it as an argument or is there else some other way to handle the binding and manipulating of the SimpleSelection instance so that a change in it shows up on rerender. Or is this simply a bug of the extended data table? ... I also just stumbled upon a similar method that I use for a ScrollableDataTable which works fine without having the table component.
Anyway, any help would be greatly appreciated. Thanks!
Greetings,
Johannes