public class RawPaginator extends Object implements Serializable
Paginator
is tied to models, where each model
collects all columns from underlying table.
This class can be more efficient because it allows to load only the columns you need to display on the UI.
This class supports pagination of result sets in ActiveJDBC. This is useful for paging through tables. If the
This class is thread safe and the same instance could be used across multiple web requests and even
across multiple users/sessions. You can generate an instance each time you need one,
or you can cache an instance in a session or even servlet context.Constructor and Description |
---|
RawPaginator(String tableName,
String[] columns,
int pageSize,
String subQuery,
Object... params)
Convenience constructor.
|
RawPaginator(String dbName,
String tableName,
String[] columns,
int pageSize,
boolean suppressCounts,
String subQuery,
Object... params)
Paginator is created with parameters to jump to chunks of result sets (pages).
|
Modifier and Type | Method and Description |
---|---|
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() . |
List<Map> |
getPage(int pageNumber)
This method will return a list of records for a specific page.
|
boolean |
getPrevious()
Synonym for
hasPrevious() . |
boolean |
hasNext() |
boolean |
hasPrevious() |
RawPaginator |
orderBy(String orderBy)
Use to set order by(s).
|
long |
pageCount() |
public RawPaginator(String tableName, String[] columns, int pageSize, String subQuery, Object... params)
suppressCount = false
tableName
- name of a table to usecolumns
- list of columns to select, or null
to select all columnspageSize
- number of items per page.subQuery
- - sub query to select some records, such as "last_name like ?". If null
is provided,
all records are selected without any filteringparams
- a set of parameters if a query is parametrized (has question marks '?').public RawPaginator(String dbName, String tableName, String[] columns, int pageSize, boolean suppressCounts, String subQuery, Object... params)
dbName
- name of databasetableName
- name of a table to usecolumns
- list of columns to select, or null
to select all columnspageSize
- 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.subQuery
- - sub query to select some records, such as "last_name like ?". If null
is provided,
all records are selected without any filteringparams
- a set of parameters if a query is parametrized (has question marks '?').public RawPaginator orderBy(String orderBy)
paginator.orderBy("category").orderBy("tab");
orderBy
- - a single "order by" expression.public List<Map> 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()
Copyright © 2016 JavaLite. All rights reserved.