]
Maksim Kaszynski commented on RF-2148:
--------------------------------------
A) To make row key to be an ID of your domain object you need to provide your own subclass
of org.richfaces.model.ScrollableTableDataModel. Additionally you need to override two
methods getId and getObjectById. getId should return unique id of your domain object - it
should be serializable (but please don't return SimpleRowKey as it's used to
determine that you redefined these methods). And getObjectById is used to retrieve your
domain object from underlying storage by its ID.
B)If you use default data model implementation you get SimpleRowKey as object's
position within sorted list.
C)Anyway, the preferred way to manipulate selection is
{code}
while(iterator.hasNext()) {
Object key = iterator.next();
table.setRowKey(key);
if (table.isRowAvailable()) {
Object o = table.getRowData();
//O is the selected object
//table is where scrollableDataTable is bound to
}
}
{code}
Selection after sorting a column in scrollableDataTable
-------------------------------------------------------
Key: RF-2148
URL:
http://jira.jboss.com/jira/browse/RF-2148
Project: RichFaces
Issue Type: Bug
Affects Versions: 3.1.4
Environment: OS X, FF2.0.0.11, JSF RI 1.2_07, Facelets 1.1.14, Jetty 6.0.1,
RichFaces 4.1.4GA
Reporter: Claus Nyhus
Assigned To: Maksim Kaszynski
Fix For: 3.2.0
Hi,
I think I have found a bug in the way the scrollableDataTable handles selection after a
column has been sorted.
The problem can be seen by using the richfaces demo application.
Without sorting, select e.g. the first row in the table, and press the button to show the
data from that row. Works fine. Now try and sort the second column, and after that again
select the first row and press the button. The data that is show is the data that would
have been in the first row if it had not been sorted.
My application is very similar to the example, except that the data is beeing shown in
the table has an id. So I figured that I would have to use the rowKey attibute on the
scrollableDataTable component in order for it to use the id of the data object instead of
the default one. This looks like this:
<rich:scrollableDataTable value="#{organisationsBB.organisations}"
var="org" sortMode="single"
rowKey="${org.id}" selection="#{organisationsBB.selection}"
id="organisationsTable">
...
</rich:scrollableDataTable>
When pressing the button, my action method does something like this:
Iterator<SimpleRowKey> iterator = selection.getKeys();
while(iterator.hasNext()) {
SimpleRowKey key = iterator.next();
int index = key.intValue();
}
I would have thought that the value of "index" would have been the value of the
id of my data object, but still, it is only the index into the list as it is presented in
the table.
Am I doing something wrong here, or is this indeed a bug ?
Hope for your help
Cheers
/Claus
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: