|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
ObjectPagerModel
public class PagerModel
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 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 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 3Random page access can also be accomplished using the
encodeRowForPage(int)
method which will return
the row number to display when jumping to a specific page in a grid.
Field Summary | |
---|---|
static int |
DEFAULT_PAGE_SIZE
|
static int |
DEFAULT_ROW
|
Constructor Summary | |
---|---|
PagerModel()
Default constructor. |
Method Summary | |
---|---|
int |
encodeRowForPage(int page)
Get the row needed to jump to the given page |
int |
getDataSetSize()
Set the data set size. |
int |
getDefaultPageSize()
Get the default page size. |
int |
getFirstPage()
Get the page number of the first page. |
int |
getLastPage()
Get the page number for the last page. |
int |
getLastRowForPage()
Get the last row for the current page of data. |
int |
getNextPage()
Get the page number for the next page. |
int |
getPage()
Get the page number given the current page size and current row. |
String |
getPageAction()
Get the action used when building URLs for navigating to another page. |
int |
getPageCount()
Get the total number of pages. |
String |
getPageHref()
Get the href used when building URLs for navigating to another page. |
int |
getPageSize()
Get the current page size. |
int |
getPreviousPage()
Get the page number of the previous page. |
int |
getRow()
Get the current row. |
int |
getRowForFirstPage()
Get the row used to display the first page. |
int |
getRowForLastPage()
Get the row used to display the last page. |
int |
getRowForNextPage()
Get the row used to display the next page. |
int |
getRowForPreviousPage()
Get the row used to display the previous page. |
void |
setDataSetSize(int dataSetSize)
Set the data set size. |
void |
setDefaultPageSize(int pageSize)
Set the default page size. |
void |
setPage(int page)
Set a specific page. |
void |
setPageAction(String pageAction)
Set the action used to navigate to another page. |
void |
setPageHref(String pageHref)
Set the href used to navigate to another page. |
void |
setPageSize(int pageSize)
Sets the page size and overrides the default page size if one has been set. |
void |
setRow(int row)
Set the current row. |
Methods inherited from class Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int DEFAULT_PAGE_SIZE
public static final int DEFAULT_ROW
Constructor Detail |
---|
public PagerModel()
DEFAULT_ROW
.
Method Detail |
---|
public String getPageAction()
null
if no action name is setpublic void setPageAction(String pageAction)
pageAction
- the action namepublic String getPageHref()
null
if no href is setpublic void setPageHref(String pageHref)
pageHref
- the hrefpublic int getDefaultPageSize()
setDefaultPageSize(int)
this
value is DEFAULT_PAGE_SIZE
public void setDefaultPageSize(int pageSize)
pageSize
- the new page size
IllegalArgumentException
- if the page size is less than 1public int getDataSetSize()
getRowForLastPage()
the default PagerModel implementation must
know the total size of the data set.
public void setDataSetSize(int dataSetSize)
dataSetSize
- the sizepublic int getPageSize()
public void setPageSize(int pageSize)
pageSize
- the specific page sizepublic int getPage()
public void setPage(int page)
page
- the new page
IllegalArgumentException
- if the given page is less than zeropublic int getRow()
public void setRow(int row)
row
- the new row
IllegalArgumentException
- if the given row is less than zeropublic int getLastRowForPage()
Get the last row for the current page of data. This value is useful when displaying paging UI like:
Row 11 through 20 of 60The 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.
public int getRowForFirstPage()
public int getRowForPreviousPage()
public int getRowForNextPage()
public int getRowForLastPage()
IllegalStateException
- when the size of the data set has not been setpublic int encodeRowForPage(int page)
page
page
- the new page
IllegalArgumentException
- if the given page value is less than zeropublic int getPageCount()
Page 4 of 10This 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.
IllegalStateException
- when the size of the data set has not been setpublic int getFirstPage()
public int getPreviousPage()
public int getNextPage()
public int getLastPage()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |