Primefaces LazyModel datatable always calls for first=0 pageSize=10

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.

Answers


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

selectParts = new LazyDataModel<SitePart>(){

Try to put p:dataTable inside h:form

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

Need Your Help

Get Goutte to work on shared host?

php server goutte

I installed Goutte on my local host using Composer. It works as expected when run using XAMPP. Then, I uploaded all the files from the vendor folder to server. Now, the script shows errors like:

Error in initializing a java.sql.Date

java date datetime jdeveloper

I am creating a project in JDeveloper, based on EJB. I have a feature that inserts a date in the Oracle database, so I want to test it if it works correctly.