I'm trying to figure out how to do true pagination with richfaces datascroller.
Currently my query pulls all of the data from a table and i want it so when you click the next button of the datascroller, it will query the db for the next 20 rows.
I understand how to write the query to limit the rows, but i'm not sure how to get the datascroller's next button to call a specific method.
I see there are many people posting on the Richfaces forums with potential solutions, but they all use a dataModel. Since i'm not using an ORM, i'm not sure how i can fit these solutions to what i have.
Any help is appreciated.
<rich:extendedDataTable id="resultsTable" value="#{tableBacking.results}" var="results" sortMode="single" rowKeyVar="row">
<rich:columns value="#{tableBacking.columns == null ? '' : tableBacking.columns}" var="columns" index="ind" id="column#{ind}" sortBy="#{results[ind].data}" rendered="#{tableBacking.columns != null}">
<f:facet name="header">
<h:outputText value="#{columns.columnDescription}" />
</f:facet>
<h:outputText value="#{results[ind].data}" />
</rich:columns>
</rich:extendedDataTable>
<rich:datascroller for="resultsTable" page="#{tableBacking.page}" renderIfSinglePage="false" />
Backing bean
public class TableBacking {
private List<List<TableData>> results = null;
private int page = 0;
public int getPage() {
return page;
}
public void setPage(int page) {
this.page = page;
}
public List<List<TableData>> getResults() throws Exception {
return results;
}
public void setResults(List<List<TableData>> results) {
this.results = results;
}
private void getData(String whereClause) {
try {
DataDao dd = new DataDao();
results = dd.getData(); // dd.getData just runs a query on a table and puts the results in a List of lists.
} catch (Exception e) {}
}