Search code examples
xpagesxpages-ssjs

pager control. Hide previous/next programmatically


On a custom control I have a repeat control which iterates over a vector. This repeat control does have a pager bound to it. I want to hide the previous and next links when the pager is on the first or on the last page of the control.

To hide the previous is ofcourse easy >> Add a rendered property to getpageCount() > 0. The next link is a bit of a problem. The pager class does not have a method getCurrentPage(). therefore I can't find out which page I'm currently at on the pager.

Is there someone who does have a fix / idea on how to hide/show the next / previous links on a pager using SSJS?


Solution

  • You can get the number of items in Vector (A) You also know the number of items you are going to display in 1 page of your repeat control(B) So total number of pages will be mod(A/B)+1 . If you are in that page, you can hide the next button.

    Mod(modulo) means to skip the decimal part or integer division.