I'm using PrimeFaces 6.1 and I'm dealing with a table like this
<p:dataTable
id="listingsTable"
value="#{listingsController.listingsLazyDataModel}"
var="actualAd"
paginator="true"
rows="20"
lazy="true"
paginatorTemplate="{FirstPageLink} {PreviousPageLink} {CurrentPageReport} {NextPageLink} {LastPageLink}"
rowsPerPageTemplate="10,20,30"
paginatorPosition="bottom"
widgetVar="listingsTableDesktop">
<p:ajax event="page" listener="#{listingsController.pageChanged}" oncomplete="pageChangedOnDetails(PF('listingsTableDesktop'))" />
</p:dataTable>
and the javascript is the following
function pageChangedOnDetails(listingsTableDesktop) {
console.log("paginaDestinazione1="+listingsTableDesktop.paginator.getCurrentPage());
console.log("paginaDestinazione2="+listingsTableDesktop.paginator.currentReport[0].innerText);
}
The problem is that all the two lines of code inside the pageChangedOnDetails function return always the page on which the user was before the page event.
Seems to be the "onComplete" is called before the dom is updated.
Is it the expected behaviour? Am I doing something wrong?