I am currently working with JSF 2 and Primefaces 5.2, more precisely with p:dataTable
.
I use p:dataTable
with pagination.
From my Java bean, I can't find a way to retrieve any pagination component. I am particularly interested in an object where I can get the
selected element in {RowsPerPageDropdown}
<p:dataTable
var="item"
value="#{items}"
rows="10"
id="tableItems"
paginator="true" paginatorPosition="top" paginatorAlwaysVisible="true"
paginatorTemplate="{CurrentPageReport} {PreviousPageLink} Page : {JumpToPageDropdown} {NextPageLink} NbrElements : {RowsPerPageDropdown}"
rowsPerPageTemplate="#{fn:length(items)},10,20,50"
currentPageReportTemplate="{startRecord}-{endRecord} / {totalRecords}" binding="#{tableComponent.table}">
By inspecting the page, the drop down menu id is tableItems_rppDD
.
I tried finding it by printing component id out with
a combination of FacesContext.getCurrentInstance().getViewRoot()...getChildren()
and findComponent()
but with no success.
Does anyone know how to get my hand on the paginator or if it is possible? Or is it a pure Javascript object?
Thanks a lot
Edit:
I am adding dynamically elements to my list (p:dataTable
+ h:commandLink
) .
If you look the dataTable declaration, the first element of the {RowsPerPageDropdown}
is the number of elements in the new list (let's call it n
).
The first time around, if I select this first element from {RowsPerPageDropdown}
, it displays n
elements.
If I add a new element in the list, the first element of the {RowsPerPageDropdown}
becomes n + 1
But the total number of elements displayed in the table is n
(the newest element is in the next page).
I have fixed my problem by reimplementing with minor changes {CurrentPageReport}
:row
– Kukeltje