Showing posts with label Pagination. Show all posts
Showing posts with label Pagination. Show all posts

Wednesday, 23 February 2011

Pagination In ADF

Pagination is one common requirement in many projects. But in ADF 11g we have only scrollable facility available. So it becomes quiet tedious job to handle huge data.

First create one Fusion Web Application.

And create the ADF Business Components (I have used Employees Table of HR schema (Oracle XE))





Now create your page. For saving time I have created One ADF Read Only Table by dragging EmployeesView1 from data control to the page.



Now create <af:iterator> where <af:table> tag was present . remove all the table related tags

The complete code is below.

The iterator code is like below:
<af:iterator id="i1"
                               value="#{bindings.EmployeesView1.collectionModel}"
                               var="row"
                               binding="#{pageFlowScope.testPageBean.myIterator}">


Now create one managed bean (TestPagebean.java here). I have created the bean in page flow scope.

create the value change listener and action listener.

The valuechange listener code will be like this :

UIXIterator valueIterator = getMyIterator();
        if (!valueChangeEvent.getNewValue().equals(valueChangeEvent.getOldValue())) {
            int newPage =
                Integer.parseInt(valueChangeEvent.getNewValue().toString());
            int pageStart = (newPage) * valueIterator.getRows();
            valueIterator.setFirst(pageStart);
            AdfFacesContext.getCurrentInstance().addPartialTarget(valueIterator);




Now run the page you will get desired output.

The complete code is below.









Please add in comments for queries..............