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