0

I have a "normal" paging with a dataTable. The first "load" brings in 25 items from the database. In the ajax "page" event I am bringing the following elements in blocks of 25 items. Everything works perfectly with version 5.1 of Primefaces, but in version 5.2 the onPageChange method is not called, in fact paging does nothing.

If in the ajax event "page" I add process="@this" it does call the bean, but not the specified onPageChange method but a start method marked with the @PostConstruct annotation (in this way the same first 25 items and pagination always shows these items).

<p:panel id="..."
        header="..."
        style="..."
        toggleable="true"
        toggleSpeed="200" >
    <p:dataTable var="some_var"
                id="myDataTable"
                widgetVar="pag"
                first="#{[bean].first}" <-- bean attribute
                value="#{[bean].collectionOfObjects}"  <-- loading of the first 25 elements
                rows="20"
                paginator="true"
                paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
                emptyMessage="..."
                lazy="true"
                rowIndexVar="rowIndex"
                rowStyleClass="#{(rowIndex mod 2) eq 0? '...' : '...'}">
        <p:ajax event="page"
                listener="#{[bean].onPageChange}"/> <-- load the next 25 items (successively)
        <p:ajax event="sort"
                listener="#{[bean].orderListing}"/>
        <p:column width="..."
                    headerText="..."
                    style="..."
                    sortBy="#{some_var.id}"
                    id="...">
            ...
        </p:column>
        [rest of columns]
    </p:dataTable>
</p:panel>

Back (just as an outline):

@PostConstruct
protected void init() {
    ...
    this.collectionOfObjects = new GenericLazyModel<CollectionOfObjects>(...);
}

//Method not called by ajax.
public void onPageChange(PageEvent event) {
    //Next 25 items
    this.collectionOfObjects = new GenericLazyModel<CollectionOfObjects>(...);
}

Versions: primefaces 5.2, jsf-api 2.2.2, jsf-impl 2.2.2 (updating these last two will be very expensive).

In this post there are several possibilities, but I have not managed to solve the error after reading everything carefully.

commandButton/commandLink/ajax action/listener method not invoked or input value not set/updated

Thank you very much to all!

Jose
  • 71
  • 7
  • What's your bean scope? From [migration guide](https://github.com/primefaces/primefaces/blob/master/docs/migrationguide/6_0.md), the only related variation could be `Per default, DataTable now skips processing child components for some events like paging. If you need child processing, you can set skipChildren="false" on p:ajax.` – WoAiNii Sep 20 '21 at 20:40
  • I've tried adding skipChildren="false" on p: ajax and it still doesn't work. I have also added `process="@this"` in the ajax call. My scope is @ViewScoped, but I have also tried with `@RequestScoped` and `@SessionScoped`. None of it seems to work :( – Jose Sep 22 '21 at 09:26
  • 1
    PF 5.2 is quite old is upgrading that an option? – Melloware Sep 25 '21 at 16:12
  • Given the size of the project, it is not possible. I have tried version 5.0 and 5.3 and the application does not work. I am looking for version 5.2.24 that seems to be the last version of the 5.2 branch and that solves several bugs, perhaps this is the solution (the behavior that I describe is a bug), but I cannot find this version of the library anywhere . – Jose Oct 11 '21 at 12:08

1 Answers1

0

Finally, after several tests, I have updated the version of PF to 5.3 and it has worked. The error when updating to this version 5.3 was not from the application itself, it was from the primefaces-extensions library that had to be updated to v4.0.0 (at least). If anyone has a problem updating the PF library, check the version of primefaces-extensions as well.

Jose
  • 71
  • 7