Thursday, April 11, 2013

How To Control ADF Table Pagination on Runtime and Do Case Insensitive Search

I decided to update my sample app from previous post - ADF 11g PS6 - ADF 10g Table Pagination Feature is Back Finally with option to change page size dynamically on runtime. Change between scroll and page mode is implemented, plus case insensitive table column filter option is enabled. Updated sample - TablePaginationApp_v3.zip comes with choice list to select page size:


There is button to force page size change, it calls af:setPropertyListener:


Listener is copying selected page size from choice list and sets Range Size in table iterator. Table Fetch Size by default is set to be equal iterator Range Size - this is how we can change dynamically table page size:


FetchSize is equal table iterator Range Size:


Switch between scroll and page modes is implemented in backing bean - changing scroll policy and doing surrounding panel collection PPR:


By default, when table is loaded - 10 rows are displayed:


You can change to 25 rows:


Switch between scroll and page modes from panel collection menu:


Rendering scroll mode now - no option to change page size, all rows are displayed:


This is how we can control table layout.

Let's see how column case insensitive search works - this is just one property change for the af:column tag. Try to search for First Name - "steven":


There will be no results - by default case sensitive search is executed in ADF table:


How to enable case insensitive search for af:column - easy. Select af:column you want to apply case insensitive search:


Set "caseInsensitive" for FilterFeatures property of af:column:


Search again for "steven" - this time result is available:


32 comments:

  1. This is the new version 11.1.1.7.0 of JDeveloper and ADF, right? Could you explain me what the PSx mean?

    Thank you

    ReplyDelete
  2. PS6 is just a short name for 11.1.1.7.

    Andrejus

    ReplyDelete
  3. This comment has been removed by the author.

    ReplyDelete
  4. Hi,

    I tested now, it works as expected. After sorting - pagination doesnt disappear.

    Andrejus

    ReplyDelete
  5. Also when i try to change the rangeSize of my tableVO from backing bean by setRangeSize(int), it doesnt get replected in the page

    ReplyDelete
  6. You should double check my sample app, it all works there.

    Andrejus

    ReplyDelete
  7. Hi,

    Thanks for your reply.
    If I add a setPropertyListener inside the button it works fine.
    But when i try to change it in my backing bean, it doesn't get reflected on the screen.

    ReplyDelete
  8. Nikhil, Just retrieve the iterator used for the table and call setRangeSize on the iterator as well setRangeSize on VO..this way it works.

    Regards

    Mikhail

    ReplyDelete
  9. Hi Andrejus,

    I have a requirement to move to next page programmatically. I have a rangeSize 10 defined which will fetch 10 records/page, but based on some business logic i need to move to next page(or nth page).
    Details of the thread is available at : https://forums.oracle.com/thread/2572122

    Can you please suggest something .

    ReplyDelete
  10. You can use out of the box table pagination available from PS6.

    Andrejus

    ReplyDelete
  11. Hi Andrejus,
    I am using new version 11.1.1.7.0 of JDeveloper and use the property scrollpolicy = 'page' and deployed the application on weblogic server 10.3.5.0 den Table pagination is working fine.
    But when we are using weblogic server 10.3.6.0 It is giving error:-


    Error 500--Internal Server Error
    weblogic.servlet.jsp.CompilationException: Failed to compile JSP /search.jspx
    search.jspx:352:29: This attribute is not recognized.
    scrollPolicy="page" autoHeightRows="0">

    ReplyDelete
  12. May be there is no correct ADF runtime on this newer server?

    Regards,
    Andrejus

    ReplyDelete
  13. Hi
    I am achieving the pagination functionality.
    Pagination nav bar is displaying below the table.
    I need to display the pagination nav bar above the table.

    Could you please suggest how to achieve the same?

    ReplyDelete
  14. Hello Andrejus

    I need help to implement your example.
    I don't understand how to force table to execute query after clicking on the "Change" button.
    I execute your example and it works fine but when I'm trying to redo the same thing, I have to refresh my all web page to see Range Size modification.

    If you could help me, thanks

    ReplyDelete
  15. Andrejus, I found a solution for my refresh problem.

    I'm using new Jdevelopper 12C and by default, it adds into web.xml deployment profile a context-param name "oracle.adf.view.rich.SYNCROWS" enabled by default.

    I removed thes line from web.xml file and now it's working as expected.


    oracle.adf.view.rich.SYNCROWS
    enable


    Hope that this will help.

    ReplyDelete
  16. i have this problem: my rangeSize=50 and the query return a greater number of rows(1700), my boss does not want a rangeSize that big becouse the app is getting slower, the problem reside when i want to select one row, gives me the null pointer exception only when the size of the query is bigger than the rangeSize, if the query returns 50 or less rows everithing works fine, what should i do if i can´t move the rangeSize from there?

    ReplyDelete
  17. I'm not sure, this would require testing your app. Ask your boss to hire us to help :-)))

    Andrejus

    ReplyDelete
  18. Hi,
    I have a requirement of ADF table pagination and select table row by using check box.
    But when i go to next page using pagination and then come back to the first page the selected checkbox value getting reset.
    I have checked the update property of the attribute is also marked as always and in the VO tuning 'persist transient attributes' is also marked.
    Still the checkbox values getting reset.

    ReplyDelete
  19. Thanks Thomas Lassauniere...It helped!!!

    ReplyDelete
  20. Hi, Andrejus!
    Please tell me why your example works on ADF 12.1.3.0.0 and does not work on 12.2.1.0.0 and 12.2.1.1.0?

    ReplyDelete
  21. You should ask this question Oracle Support. I can't guarantee any solutions would work across releases :)

    Regards,
    Andrejus

    ReplyDelete
  22. Oh, thank to Thomas Lassauniere!
    Setting oracle.adf.view.rich.SYNCROWS = disable, and everything works!

    ReplyDelete
  23. Hi Andrejus

    thanks for the great tutorial

    In case I select the second page and change the range size then I expect the paging goes to the first page
    I retrieve the iterator in a bean and setRangeSize as well as setRangeStart(0) but Its failed to reset to the first page

    thank you

    ReplyDelete
  24. I would not recommend using oracle.adf.view.rich.SYNCROWS = disable, this could lead to out of synch between ADF View fetch size and ADF model range size. You could start seeing scenarios when data is saved for different row, not the one selected on UI.

    Regards,
    Andrejus

    ReplyDelete
  25. Hi Andrejus,

    I am facing one issue related to table pagination.
    I have a checkbox in the table which is derivied from POJO data control.
    I have applied scroll policy as "page" for pagination purpose .
    The checkbox value is not retained while traversing to and fro.
    Please let me know how to handle this

    ReplyDelete
  26. Hi;

    Could you please provide an active link?

    ReplyDelete
  27. You can download old samples from here - https://code.google.com/archive/p/jdevsamples/downloads

    Andrejus

    ReplyDelete
  28. Hi,

    I am facing a issue in pagination like when i select a row on 2nd or 3rd page and do some operations and again click on search brings me to 2nd page while it should give me 1st page instead
    can you help with this.

    ReplyDelete
  29. the src source is not found in server..could you provide the new website to download it.tks

    ReplyDelete
  30. Hi,
    Am using Jdev 12c. My current application has ADF table with pagination. The requirement is to show the pagination bar on top as well as bottom of the page.
    Any idea how can this be acheived in 12c?
    I tried for setting table_control-bar-position after reading few blogs, but this doesn't seem to be a valid attribute anymore.
    Also, with skinning, I can only have the navbar at one place, but my requ is to have at both places. Is this possible without custom bean code?

    ReplyDelete
  31. Hi Andrejus,

    I am trying to write a code which iterates all rows of range-paging VO, but even after changing the page by calling scrollToRangePage(), the getAllRowsInRange() is always returning same set of rows.

    What I could be missing?

    public void excludeAllAL(ActionEvent actionEvent) {
    //
    //Code to get iterator binding
    //
    ViewObject detailVO = itrBinding.getViewObject();

    int totalPages = detailVO.getEstimatedRangePageCount();
    System.out.println("Number of pages: " + totalPages);

    for (int p = 1; p <= totalPages; p++){
    System.out.println("Moving to page: " + (p));

    detailVO.scrollToRangePage(p); //This API changes the page
    Row[] rows = detailVO.getAllRowsInRange(); //This API is supposed to get all rows for new page, but it is bringing same set of rows always

    for (Row row : rows){
    //DO SOMETHING
    }
    }
    }

    ReplyDelete