I’m not sure if this is a bug or just something that isn’t implemented but I can’t update the dataGrids page property to reset the pagination to page 1. I’ve bound it to an expression in my bean and update it via an ajax update, but it doesn’t get updated when I clicked my button. The paginator will stay on the selected page and not reset via an ajax request. I’m using to try to reset it. The dreamSearchBean’s setCurrentPage does get called and gets passed 1 but it stays at whatever page was last selected
<h:form id="dreamWebSearchFrm">
<p:commandButton styleClass="form-btn1" value="#{bundle['dreamSearch.search.button.TEXT']}" onclick="trackingDreamSearch()"
actionListener="#{dreamSearch.search}" update=":dreamWebSearchFrm:resultsPnl">
<f:setPropertyActionListener value="1" target="#{dreamSearchBean.currentPage}"/>
</p:commandButton>
<p:panel id="resultsPnl">
<div class="data-grid-wrap">
<h:outputFormat escape="false" value="#{bundle['dreamSearch.imageResults.TEXT']}" rendered="#{dreamSearchBean.shouldRender}" >
<f:param value="#{dreamSearchBean.searchText}" />
</h:outputFormat>
<p:dataGrid var="dream" value="#{dreamSearchBean.dreams}" rendered="#{dreamSearchBean.shouldRender}" page="#{dreamSearchBean.currentPage}" pageLinks="3" columns="4" rows="4" paginator="true" effect="true"
styleClass="ui-header-visibility"
paginatorTemplate="{FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink}"
paginatorPosition="bottom">
<p:column>
<h:panelGrid columns="1">
<p:commandLink onclick="webSearchDlg.hide();dreamEditDlg.show();" update=":dreamEditFrm:display">
<f:setPropertyActionListener value="#{dream}" target="#{dreamModifyBean.selectedDream}"/>
<p:graphicImage value="#{dream.imageThumb}" width="125" height="100"></p:graphicImage>
</p:commandLink>
</h:panelGrid>
</p:column>
</p:dataGrid>
</div>
</p:panel>
</h:form>
You have to extend the DataTableRenderer of Primefaces. Create a new class, maybe it could be DataTableRendererExt that extends the DataTableRenderer.
Override the
encodeMarkup(...)method, copy the origin code, and insert a call toresetPagination():To bind this extended class in your application you have to insert this block in your faces-config.xml:
There is another bug in the DataTableRenderer – lazyLoading. Data table is empty on the very first load because of incorrect placement of
table.loadLazyData()in theencodeTbody(...)method.Here is my code for the extension class: