|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.javalite.activejdbc.Paginator<T>
public class Paginator<T extends Model>
This class supports pagination of result sets in ActiveJDBC. This is useful for paging through tables. If the
Model subclass is annotated with @Cached, then this class will
cache the total count of records returned by getCount(), as LazyList will cache the result sets.
This class is thread safe and the same instance could be used across multiple web requests and even
across multiple users/sessions. It is lightweight class, you can generate an instance each time you need one,
or you can cache an instance in a session or even servlet context.
| Constructor Summary | |
|---|---|
Paginator(Class<? extends T> modelClass,
int pageSize,
boolean suppressCounts,
String query,
Object... params)
Paginator is created with parameters to jump to chunks of result sets (pages). |
|
Paginator(Class<? extends T> modelClass,
int pageSize,
String query,
Object... params)
Convenience constructor. |
|
| Method Summary | |
|---|---|
Long |
getCount()
Returns total count of records based on provided criteria. |
int |
getCurrentPage()
Returns index of current page, or 0 if this instance has not produced a page yet. |
boolean |
getNext()
Synonym for hasNext(). |
LazyList<T> |
getPage(int pageNumber)
This method will return a list of records for a specific page. |
boolean |
getPrevious()
Synonym for hasPrevious(). |
boolean |
hasNext()
|
boolean |
hasPrevious()
|
Paginator |
orderBy(String orderBys)
Use to set order by(s). |
long |
pageCount()
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public Paginator(Class<? extends T> modelClass,
int pageSize,
String query,
Object... params)
Paginator(Class, int, String, Object...) and passes true for suppressCounts.
public Paginator(Class<? extends T> modelClass,
int pageSize,
boolean suppressCounts,
String query,
Object... params)
"last_name like '%John%'" - this is a sub-query, and the rest of the information will be filled out
by this class
modelClass - model class mapped to a table.pageSize - number of items per page.suppressCounts - suppress calling "select count(*)... " on a table each time. If set to true,
it will call count only once. If set to false, it will call count each time
getCount() is called from hasNext() as well.params - a set of parameters if a query is parametrized (has question marks '?').query - this is a query that will be applied every time a new page is requested; this
query should not contain limit, offset or order by clauses of any kind, Paginator will do this automatically.
This parameter can have two forms, a sub-query or a full query.| Method Detail |
|---|
public Paginator orderBy(String orderBys)
"category, created_at desc"
orderBys - a comma-separated list of field names followed by either "desc" or "asc"
public LazyList<T> getPage(int pageNumber)
pageNumber - page number to return. This is indexed at 1, not 0. Any value below 1 is illegal and will
be rejected.
public int getCurrentPage()
public boolean getPrevious()
hasPrevious().
public boolean hasPrevious()
public boolean getNext()
hasNext().
public boolean hasNext()
public long pageCount()
public Long getCount()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||