public class PaginatorFilter extends Object implements Filter
This filter easily enables paging of data on top of your current structure.
The data that should be paged must be placed in the output stack with the
specified key (see constructor). Only arrays or Collections
can be paged, other data will be silently ignored.
The data with the specified key will be replaced by an instance of the
Paginator class which contains the paged data and some other
useful information.
Let's say you want paged search results: Add this filter to the
ActionConfig of your search action and don't forget to
pass the page parameter to the query string:
http://example.com/search.mtw?q=keywords&p=0
Paginator class to obtain
information about the amount of all data, current page, maximum page and
so on. With these information you can create links to the previous and
next pages of your paged data.
Mentawai provides the PaginatorTag, but this filter can be more useful for Ajax requests or any other situation when you don't want or cannot use the PaginatorTag.
Paginator| Modifier and Type | Field and Description |
|---|---|
static int |
DEFAULT_ITEMS_PER_PAGE |
static String |
DEFAULT_PAGE_PARAM |
| Constructor and Description |
|---|
PaginatorFilter(String key)
Instantiate a PaginatorFilter with the specified key pointing to the data
in the output stack which should be paged.
|
PaginatorFilter(String key,
int itemsPerPage)
Instantiate a PaginatorFilter with the specified key and amount of items
per page.
|
PaginatorFilter(String key,
int itemsPerPage,
String pageParam)
Instantiate a PaginatorFilter with the specified key, amount of items per
page and name of the page parameter.
|
| Modifier and Type | Method and Description |
|---|---|
static Object[] |
copyOfRange(Object[] original,
int from,
int to) |
void |
destroy()
Gives a chance to the filter to deallocalte any resources before it is destroyed.
|
String |
filter(InvocationChain chain)
The filter replaces the specified data with an instance of
Paginator which contains the paged data and some other
useful information. |
public static final String DEFAULT_PAGE_PARAM
public static final int DEFAULT_ITEMS_PER_PAGE
public PaginatorFilter(String key)
key - Key of the data from the output stack to pagepublic PaginatorFilter(String key, int itemsPerPage)
key - Key of the data from the output stack to pageitemsPerPage - Amount of items per pagepublic PaginatorFilter(String key, int itemsPerPage, String pageParam)
key - Key of the data from the output stack to pageitemsPerPage - Amount of items per pagepageParam - Name of the page parameterpublic String filter(InvocationChain chain) throws Exception
Paginator which contains the paged data and some other
useful information.
Note: Only arrays and Collections can be paged.public void destroy()
FilterCopyright © 2015. All Rights Reserved.