While trying to fix this
(http://www.nabble.com/-Trinidad--how-to-add-default-selection-for-Table-td16698321.html)
I found a strange behaviour that looks like a bug.
The table is defined like this:
<tr:table value="#{myBean.billingAdresses}" var="address" rowSelection="single"
binding="#{myBean.addressTable}" >
The method billingAddresses() returns a Collection of BillingAddress-objects.
The row displaying a certain object should be pre-selected when the table is
displayed. So, in the backing bean, there are a number of called methods to
find the right RowKey and to create the RowKeySet to set to the table using
UIXTable.setSelectedRowKeys(). This are the used methods:
public List<BillingAddress> getBillingAdresses(){
addressList = myData.getBillingAdresses(getUser(),
getJcoClient());
addressTable.setSelectedRowKeys(getSelectedRowKeys());
return addressList;
}
public RowKeySet getSelectedRowKeys(){
RowKeySet selectedRows = getMatchingRowKeys(currentAddress,
addressTable);
return selectedRows;
}
public RowKeySet getMatchingRowKeys(BillingAddress sample, CoreTable
table){
RowKeySet keySet = new RowKeySetImpl();
int rows = table.getRows();
for(int i=1;i<rows;i++){
table.setRowIndex(i); // <-- This is where the JVM
jumps back
BillingAddress rowAddress =
(BillingAddress)table.getRowData();
if(rowAddress == sample)
keySet.add(table.getRowKey());
}
return keySet;
}
The problem emerges when debugging step by step through this. Everything is
fine until getMatchingRowKeys(...) is called. In the line marked with // <!--
the debugger jumps back to the first line of getBillingAdresses(...) resulting
in an infinite loop.
My questions are:
1) Is there another way to get the apropriate RowKeys and set them to the table
2) Should I report this to JIRA or is there an error in my code that keeps
hidden from my eyes?
Please note also this posting
http://markmail.org/message/mku5h24ofwi2gnrd#query:how%20to%20RowKEySet+page:1+mid:mku5h24ofwi2gnrd+state:results
as it looks like dealing with the same problem.
Thanks,
Tom
Thomas Asel
Diplom Informatiker (FH)
Selbständiger Softwareentwickler
im Auftrag der 24/7 IT-Services GmbH
== == == == == == == == == == == ==
www.thomas-asel.de
J2EE und Contentmanagement-Lösungen
L13,7 68161 Mannheim
Tel.: +49 (0) 621 / 386 448 3
Mobil: +49(0) 176 / 219 284 26
USt-IdNr.: DE248123620