3

I am using the LazyDataModel to populate a a table with 33 items(A sub set of a long list of parts and can grow or shrink) in pages of 10. the table deceleration is as follows

<p:dataTable var="spare" value="#{sitePartController.selectParts}" paginator="true" lazy="true"
                                 currentPageReportTemplate="(Entries: {startRecord} - {endRecord} of {totalRecords}, Page: {currentPage}/{totalPages})"
                                          paginatorTemplate="{CurrentPageReport}{FirstPageLink}{PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink}"
                                          rows="10" selection="#{sitePartController.selectedParts}"
                                          paginatorAlwaysVisible="false"
                                          dynamic="true"
                                          >

The pagination works fine filling the currentPageTemplate with 33 items 4 pages 1- 10 etc. When i press a link all the pagination output changes correctly(page 2/4 etc). However the data in the table does not change, just continues to show records 0-9. My override Load method is as follows.

selectParts = new LazyDataModel() {

        @Override
        public List<SitePart> load(int first, int pageSize, String string, boolean bln, Map map) {
            return getSiteSpares(first,first+pageSize);
        }

    };
    int totalRowCount = getSparesCount();
    selectParts.setRowCount(totalRowCount);

When I stop my debug in the load method no matter which datatable pagination link I select; first is always 0 and page is 10 (as expected). How do I get the datatable to send the correct first index or have I missed something fundamental in the last 6 hours of googleing and trying various alternatives.

user845854
  • 81
  • 3
  • 9

2 Answers2

0

Try to put p:dataTable inside h:form

<h:form id="form">
    <p:dataTable>
    </p:dataTable>
</h:form>
0

Not sure if it could cause the issue, but shouldn't it be:

selectParts = new LazyDataModel<SitePart>(){
MatsT
  • 1,759
  • 3
  • 20
  • 33