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>
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>(...);
}
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!