Friday, June 24, 2016

Iterating over range paged rowsets

Recently I came across a scenario where in I had to enable Range Paging over my query based view object. In UI bean, I need to browse through all the rows if user choose select all option.
You cannot use regular viewObj.createRowSetIterator(null); to browse through all the rows. This will only allow you to browse through current range size rows.

You can use below code to browse all the rows:

public void selectAll(ActionEvent actionEvent) {
DCBindingContainer bindings = (DCBindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry();
DCIteratorBinding dcItr = bindings.findIteratorBinding("CustomQueryBasedIterator");
ViewObjectImpl viewObj = (ViewObjectImpl)dcItr.getViewObject();
int rangePageCount = viewObj.getEstimatedRangePageCount();
for ( int pageNo = 1 ; pageNo <= rangePageCount ; pageNo++ ){
viewObj.scrollToRangePage(pageNo);
Row[] rowsInCurrentPage = viewObj.getAllRowsInRange();
for(Row row : rowsInCurrentPage ){
//TODO whatever operation you want to do
}
}
}
view raw gistfile1.txt hosted with ❤ by GitHub