|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.mentawai.filter.PaginatorFilter
public class PaginatorFilter
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| Field Summary | |
|---|---|
static int |
DEFAULT_ITEMS_PER_PAGE
|
static String |
DEFAULT_PAGE_PARAM
|
| Constructor Summary | |
|---|---|
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. |
|
| Method Summary | |
|---|---|
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. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final String DEFAULT_PAGE_PARAM
public static final int DEFAULT_ITEMS_PER_PAGE
| Constructor Detail |
|---|
public PaginatorFilter(String key)
key - Key of the data from the output stack to page
public PaginatorFilter(String key,
int itemsPerPage)
key - Key of the data from the output stack to pageitemsPerPage - Amount of items per page
public 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 parameter| Method Detail |
|---|
public 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.
filter in interface Filterchain - The InvocationChain for the action this filter is being applied to.
ExceptionPaginator
public static Object[] copyOfRange(Object[] original,
int from,
int to)
public void destroy()
Filter
destroy in interface Filter
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||