Thursday, December 13, 2012

How to iterate and read the rowset of ADF Table

Let us say, we have an ADF table in our jsff file. It will have the Node binding under the bindings section of the respective page definition of the jsff and also an iterator under the executables section of page definition.

The below code fragment gets the Current Binding container.

DCBindingContainer bindings = (DCBindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry();

The below code fragment gets the iterator binding from the current binding container.

DCIteratorBinding dcIteratorBinding = bindings.findIteratorBinding("<IteratorId>");


The below code fragment gets the iterator and shows how to access a row from it using a row key.

RowSetIterator rsiRows = dcIteratorBinding.getRowSetIterator();
Row row = rsiRows.getRow(<Key object>);       

The below code fragment gets the list of selected rows in case multiple row selection is enabled.


RowKeySet rks =  <RichTable object>.getSelectedRowKeys();
Iterator it = rks.iterator();
int i = 0;


while (it.hasNext()) {
   i++;
   List selectedRowKeyPath = (List)it.next();  
   Row row = rsiRows.getRow((Key)selectedRowKeyPath.get(0));
   System.out.println("Selected Row no#"+i+" "+row.getAttribute("Name"));
}

No comments:

Post a Comment