I am designing an application where certain input feeds are entered via primefaces datatable.
Version Spec: PrimeFaces - 4.0 JSF - 2.1.6
Problem Faced: Pagination breaks after updating datatable. Looks like before an update event is triggered in datatable, pagination works perfectly. The list mapped to this datatable is under "View Scope".
Please find my XHTML code for datatable below,
<p:dataTable var="profile" value="#{manualNBean.manualNlist}"
rows="10" paginator="true" paginatorPosition="bottom"
rowIndexVar="rowIndex" lazy="true"
paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
rowsPerPageTemplate="10,50,100,200" id="statustab">
<p:column headerText="S.No">
<p:outputLabel value="#{rowIndex+1}" />
</p:column>
<p:column headerText="Profile ID">
<p:outputLabel value="#{profile.profileID}" />
</p:column>
<p:column headerText="Law Firm Name">
<p:outputLabel value="#{profile.lawFirmName}" />
</p:column>
<p:column headerText="First Name">
<p:outputLabel value="#{profile.firstName}" />
</p:column>
<p:column headerText="Second Name">
<p:outputLabel value="#{profile.secondName}" />
</p:column>
<p:column headerText="Full Name">
<p:outputLabel value="#{profile.fullName}" />
</p:column>
<p:column headerText="Profile Link">
<h:outputLink value="#{profile.profileLink}" target="_blank">#{profile.profileLink}</h:outputLink>
</p:column>
<p:column headerText="PPTS N" id="editNCol">
<p:commandButton icon="ui-icon-pencil" process="@this"
update="statustab" rendered="#{profile.editbuttonRender}"
action="#{manualNBean.turnoffRender}">
<f:setPropertyActionListener value="#{profile}"
target="#{manualNBean.manualNDTO}" />
</p:commandButton>
<p:autoComplete id="manualN" minQueryLength="3"
value="#{profile.manualN}"
style="#{profile.autocompletebuttonRender}"
completeMethod="#{manualNBean.autocompleteN}">
</p:autoComplete>
</p:column>
</p:dataTable>
Here, update action is performed in command button. Even after update action is performed, the lazy model still seem to be filled with records from database but I wonder why pagination breaks.
Note: By adding ajax="false" attribute to the button, page reloads and now the pagination seem to be working fine. However, this is not feasible and looking forward to control this with Ajax.
Just to add another note, this datatable populates information from database only after a button click.
Can anybody advise where I am going wrong?