org.apache.click.dataprovider
Interface PagingDataProvider<T>
- All Superinterfaces:
- DataProvider<T>, Serializable
public interface PagingDataProvider<T>
- extends DataProvider<T>
An interface to provide paginated data on demand to controls. It allows
specifying the total number of results represented by this DataProvider
through the size()
method.
Example usage:
public class MyPage extends Page {
private Table table = new Table("table");
public MyPage() {
...
table.setDataProvider(new PagingDataProvider() {
// Return a list of customers
public List getData() {
int start = table.getFirstRow();
int count = table.getPageSize();
return getCustomerService().getCustomers(start, count);
}
// Return the total number of customers to page over
public int size() {
return getCustomerService().getNumberOfCustomers();
}
});
}
}
Please note: when providing paginated data to controls that support
sorting e.g. Tables, you are responsible for sorting the data, as the Table
does not have access to all the data.
Here is an example demonstrating both paging and sorting:
public class MyPage extends Page {
private Table table = new Table("table");
public MyPage() {
...
table.setDataProvider(new PagingDataProvider() {
// Return a list of customers
public List getData() {
int start = table.getFirstRow();
int count = table.getPageSize();
String sortColumn = table.getSortedColumn();
boolean ascending = table.isSortedAscending();
return getCustomerService().getCustomers(start, count, sortColumn, ascending);
}
// Return the total number of customers to page over
public int size() {
return getCustomerService().getNumberOfCustomers();
}
});
}
}
Method Summary |
int |
size()
Return the total number of results represented by this DataProvider. |
size
int size()
- Return the total number of results represented by this DataProvider.
- Returns:
- the total number of results represented by this DataProvider