Ajax event in pagination with Primefaces 5.2 dataTable not working

UI Components for JSF
Post Reply
Jose2021
Posts: 1
Joined: 11 Oct 2021, 13:55

11 Oct 2021, 14:01

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).

Code: Select all

<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):

Code: Select all

@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 stackoverflow post there are several possibilities, but I have not managed to solve the error after reading everything carefully.

https://stackoverflow.com/questions/211 ... nput-value

Thank you very much to all!

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 34 guests