David,
You should be able to bind table's "selectedRowKeys" to a property on
your model
or a backing bean that has the same lifespan as the model. When the
getter is called for the first time,
allocate a new instance of RowKeySetImpl and cache it. Then use the
add() method to add a desired
row key to the set.
Hope this helps,
Max Starets
David Uebelacker wrote:
Hi,
i'm trying to select a row in a table programatically.
I wrote follwing method to to that:
----------------------------------------
public static void selectDatas( CoreTable pCoreTable, Object... pDatas )
{
Object tCurrent = pCoreTable.getRowKey();
RowKeySet tRowKeySet = pCoreTable.getSelectedRowKeys();
tRowKeySet.clear();
for ( int i = 0; i < pCoreTable.getRowCount(); i++ )
{
pCoreTable.setRowIndex( i );
Object tRowData = pCoreTable.getRowData();
for ( Object tObjectToSelect : pDatas )
{
if ( tRowData == tObjectToSelect || tRowData.equals(
tObjectToSelect ) )
{
tRowKeySet.setContained( true );
}
}
}
pCoreTable.setSelectedRowKeys( tRowKeySet );
pCoreTable.setRowKey( tCurrent );
}
----------------------------------------
This works fine, but i don't know where to execute this method. I have
bound the table to my backing bean and tried to select the rows in the
getTable method. This works aside from the first row.
The Problem is, that the table model is added to table after the first
access to the getTable method and my code does not work without the model
in the table.
Any ideas or better solution ?
Thanks,
David