T
- The type of item being displayedpublic class ListPager<T> extends Object
This class provides an easy way to page through a filterable list of items from a JSP page.
It is up to the caller of the class to specify the filter, if required, in the form of a
predicate
. To ensure that search parameters are maintained when paging through
the list, it's also necessary to supply a list of input field identifiers that should be included as part of the
request when accessing another page. These field identifiers are used to extract the value of the field, and copy it
to a hidden form that is used for the actual submission. This means each search criteria has two form fields
associated with it - the visible field that the users types in, and in the hidden form that is submitted.
The reason for this is that the location of the input fields on the screen may not always be appropriate for a form - for example, if the fields are location within a table, the form must wrap the whole table, which would preclude the use of any other forms within cells in that table.
These input fields will also be modified so that pressing Enter/Return when the fields has focus will automatically submit the form.
Constructor and Description |
---|
ListPager(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
List<T> items,
Predicate<T> filter,
String... additionalFormFields)
Creates a unfiltered list pager.
|
ListPager(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
List<T> items,
String... additionalFormFields)
Creates a unfiltered list pager.
|
Modifier and Type | Method and Description |
---|---|
int |
getCurrentPageNumber() |
int |
getFilteredItemCount() |
int |
getFirstItemNumberOnPage() |
String |
getHiddenFields() |
List<T> |
getItemsOnCurrentPage() |
String |
getJumpToPageForm() |
int |
getLastItemNumberOnPage() |
String |
getPageFunctions() |
String |
getPageLinks() |
int |
getPageSize() |
String |
getPageSizeSelection() |
static String |
getQueryString(javax.servlet.http.HttpServletRequest request,
char prefix,
String... additionalFormFields) |
int |
getTotalItemCount() |
int |
getTotalPages() |
boolean |
isFiltered() |
public ListPager(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, List<T> items, String... additionalFormFields)
request
- the request object for the page in questionresponse
- the response object for the page in questionitems
- the list of items to display on the pageadditionalFormFields
- 0 or more input field identifiers (NOT form field names) to include in requests for other pagespublic ListPager(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, List<T> items, Predicate<T> filter, String... additionalFormFields)
request
- the request object for the page in questionresponse
- the response object for the page in questionitems
- the complete list of items to display on the pagefilter
- the filter to apply to the complete listadditionalFormFields
- 0 or more input field identifiers (NOT form field names) to include in requests for other pagespublic int getTotalItemCount()
public int getFilteredItemCount()
public List<T> getItemsOnCurrentPage()
public int getCurrentPageNumber()
public int getPageSize()
public int getFirstItemNumberOnPage()
public int getLastItemNumberOnPage()
public int getTotalPages()
public boolean isFiltered()
true
if the the supplied filter has restricted the number of items to display, otherwise false
public String getPageSizeSelection()
public String getPageLinks()
public String getHiddenFields()
public static String getQueryString(javax.servlet.http.HttpServletRequest request, char prefix, String... additionalFormFields)
request
- The request to retrieve the values fromprefix
- The first char of the query string - either `?` or `&`additionalFormFields
- 0 or more form field names to include in requests for other pagespublic String getJumpToPageForm()
public String getPageFunctions()
Copyright © 2003–2019 Ignite Realtime. All rights reserved.