|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.javalite.activejdbc.Paginator
public class Paginator
This class supports pagination of result sets in ActiveJDBC. This is useful for paging through
tables. This class does not cache resultsets, rather it will make requests to DB
each time getPage(int) method is called.
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 Model> modelClass,
int pageSize,
String query,
Object... params)
Paginator is created with parameters to jump to chunks of result sets (pages). |
|
| Method Summary | ||
|---|---|---|
long |
getCount()
Total count of records based on provided criteria. |
|
int |
getCurrentPage()
Returns index of current page, or -1 if this instance has not produced a page yet. |
|
boolean |
getNext()
Synonym for hasNext(). |
|
|
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 Model> modelClass,
int pageSize,
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.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 <T extends Model> 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 | |||||||||