The PagerModel is a JavaBean that represents the page state of a data grid. In the default implementation,
the page state consists of three pieces of data:
the current row
current page
the href / action used to page through data
This pager model implementation is row based which means that the notion of the current page
is based on which row is at the top of a page. Row numbering starts at zero and continues to page size.
For example, in a data grid on its first page and with a page size of 10, the rows 0-9 will be displayed. The
next page would contain rows 10-11 and so on.
The pager model provides JavaBean-style access to the properties of a pager. In addition, it provides read-only
access to information about the row to use in order to navigate to a specific page. To navigate to the previous
page, the
PagerModel.getRowForPreviousPage() will return the row number that will appear at the top of the previous
page. In order to build effective paging UI, it is also often useful to know the absolute page number.
As with row numbers, page numbers are zero based. For example, if a data set displayed in a data grid has 30
records and the grid is on page a page displaying rows 10-19, the current page is 1. When displaying this value
in UI, it is often useful to display it as:
Page 2 of 3
Random page access can also be accomplished using the
PagerModel.encodeRowForPage(int) method which will return
the row number to display when jumping to a specific page in a grid.
Get the row needed to jump to the given page Parameters: page - the new page the row used to jump to the new page throws: IllegalArgumentException - if the given page value is less than zero
Set the data set size. In order to calculate paging state for the last page such as the
state returned for
PagerModel.getRowForLastPage() the default PagerModel implementation must
know the total size of the data set.
the size
Get the last row for the current page of data. This value is useful when displaying paging UI like:
Row 11 through 20 of 60
The last row on the page is returned as a zero-based number from the beginning of the data set. In the
case above, the value returned is 19 and is converted to 20 for readability
by adding one. If the current page is only partially filled, this method will return the value for a partial page.
For example, with a data set of size 4 on a page of size 10, the value 3 would be returned.
the last row for the current page
Get the page number given the current page size and current row. The page number is zero based and should be
adjusted by one when being displayed to users.
the page number
Get the total number of pages. This value is useful when displaying the total number of pages in UI like:
Page 4 of 10
This method returns an absolute count of the number of pages which could be displayed given the
size of the data set and the current page size. This method requires the PagerModel know the
total size of the data set.
the number of pages throws: IllegalStateException - when the size of the data set has not been set
Get the row used to display the last page. This requires tha the data set size has been set via
the row for the last page throws: IllegalStateException - when the size of the data set has not been set
Get the row used to display the next page. Note, if this value is greater than the size of the data set
it would scroll off the end of the data set and is invalid.
the row for the previous page
Get the row used to display the previous page. Note, a return value of less than zero means that the previous
page does not exist as it would scroll off the beginning of the data set and is invalid.
the row for the previous page
Set the data set size.
Parameters: dataSetSize - the size
setDefaultPageSize
public void setDefaultPageSize(int pageSize)(Code)
Set the default page size. The default page size is used when no other page size has been set and is useful
when clients wish to occasionally override the page size but wish to have the default page size set
differently than the PagerModel's default.
Parameters: pageSize - the new page size throws: IllegalArgumentException - if the page size is less than 1
Set a specific page. This will change the current row to match the given page value.
Parameters: page - the new page throws: IllegalArgumentException - if the given page is less than zero
setPageAction
public void setPageAction(String pageAction)(Code)
Set the action used to navigate to another page.
Parameters: pageAction - the action name