Note that there are some explanatory texts on larger screens.

plurals
  1. POPrimefaces - Custom Pagination/ Sorting load() issue
    primarykey
    data
    text
    <p>We are using Primefaces 3.0.RC2 in our application with seam faces and CDI. We have followed the lazy loaded data table implementation on the component showcase. Since we have a large dataset, we have overridden the load() method to fetch only pagewise results. (vs loading all records in memory at once).</p> <p>The pagination works as expected, however the sorting does not. The records get sorted correctly the first time the column header is clicked. For all subsequent clicks, the load() method is called twice, sending different values for the sorting order as a result of which, the sort order remains the same on the table. It seems like both the load() calls are being made in the APPLY_REQUEST_VALUES phase.</p> <p>Can anyone provide any inputs as to why this is happening and how it can be avoided. Any pointers would be highly appreciated.</p> <p>Some additional info: As stated earlier, we have overriden the load() method and have it actually query the DB to fetch sorted results pagewise (by specifying max results and order by in the query) and it works fine. </p> <pre><code>@Override public List&lt;ABC&gt; load(int first, int pageSize, String sortField, SortOrder sortOrder, Map&lt;String, String&gt; filters) { // Fetch data pagewise from the database datasource = dao.findPagewiseSortedResults(sortField, SortOrder.ASCENDING == sortOrder ? true : false, first, pageSize); // Set the row count this.setRowCount((int) dao.findTotalCount()); return datasource; } </code></pre> <p>However, on clicking the column on the datamodel for sorting, 2 post requests are made.</p> <p>Find below the xhtml code:</p> <pre><code> &lt;p:dataTable id="dataTable" var="record" value="#{testBean.lazyModel}" paginator="true" rows="5" paginatorTemplate="{FirstPageLink} {PreviousPageLink} {CurrentPageReport} {NextPageLink} {LastPageLink}" selectionMode="single" selection="#{testBean.selectedRecord}" sortBy="#{record.username}"&gt; &lt;p:ajax event="rowSelect" listener="#{testBean.onRowSelect}" update=":form:display" oncomplete="accountDialog.show()" /&gt; &lt;p:ajax event="colResize" update=":form:growl" listener="#{testBean.onResize}" /&gt; &lt;p:column sortBy="#{record.username}" filterBy="#{record.username}"&gt; &lt;f:facet name="header"&gt; &lt;h:outputText value="User Name" /&gt; &lt;/f:facet&gt; &lt;h:outputText value="#{record.username}" /&gt; &lt;/p:column&gt;......... &lt;/dataTable&gt; </code></pre> <p>We have even upgraded to the latest Primefaces version (3.0.1) but it hasn't helped. Are we missing anything? Any pointers would be very helpful.</p> <p>Thanks.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload