This is a small code snippet on how to avoid selection-state reset of an ADF table when the underlying method is re-queried.
Assuming that you have a Master-Detail situation. Lets says, you have a methodAction e.g. id="findAllItems" and an associated methodIterator e.g. id="findAllItemsIter", then following is the code snippet that you can use in the page's managed backing bean to avoid selection-state reset.
public void refreshButRetainSelection(){
CoreTable table=this.getMasterTable();
RowKeySet rowSet=table.getSelectionState();
OperationBinding operationBinding=
bindings.getOperationBinding("findAllItems");
operationBinding.execute(); // requery
table.setSelectionState(rowSet);
Set keySet=table.getSelectionState().getKeySet();
Iterator rowSetIter=keySet.iterator();
DCIteratorBinding iterBinding=
(DCIteratorBinding)bindings.get("findAllItemsIter");
while(rowSetIter.hasNext()){
Key key=(Key)rowSetIter.next();
iterBinding.setCurrentRowWithKey(key.toStringFormat(true));
}
}
No comments:
Post a Comment