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


3 comments:

  1. Hi Bhargav,

    Thank you for the detailed blog.

    I am trying to write a similar code but even after changing the page by calling scrollToRangePage(), the getAllRowsInRange() is always returning same rows.

    What am I missing?

    Regards
    Ravi Sharma

    ReplyDelete
    Replies
    1. Can you check your view objects access mode is Scrollable under tuning section ?

      Delete
    2. No Bhargav, I have configured it to be "Range Paging". So basically I have done everything which your blog and this blog says: https://techiecook.wordpress.com/2010/08/26/using-range-paging-in-adf-an-example/

      Still I get same set of rows when I call getAllRowsInRange().

      Delete