Kodiyan
Kodiyan

Reputation: 377

Primefaces Data Table Total Records with Paginator

I am using Primefaces 5.1 and displaying total records in index.xhtml and it is perfectly working fine if I am NOT using paginator.

<h:body>
    <div id="message">
    <p>There are #{uBean.dataTable.rowCount} matching records.</p>
    </div>
    <h:form>
       <p:tabView widgetVar="tabWidget" id="rTab" cellpadding="0px" cache="true">

When I start using paginator for my primefaces table, then I see the records are showing from the previous rendered count. Is there any way to refresh to display after load the page or delay to display this div or any other simple solutions. ----

Upvotes: 0

Views: 3270

Answers (1)

Kukeltje
Kukeltje

Reputation: 12337

PrimeFaces loads/processes data for the datatable in the RenderResponse phase. This is very late in the jsf phases and that means that e.g. the rowcount or pagenumber is only available for components that are rendered after the datatable and that in turn means only for components that in the xhtml come after the datatable.

If you want to display things in a growl, this is usually not a problem since it displays at a 'absolute' location and you can put it after the datatable. But rendering it in a different kind of component and displaying it inline is not possible without a workaround.

For a workaround, you have two options

  1. Put your component after the datatable and in an oncomplete of an ajax call, use jquery dom manipulation to move it in front of the datatable
  2. Use the OmniFaces moveComponent to achieve the same result

Upvotes: 1

Related Questions