I have upgraded PrimeFaces from 5.1 final to 5.2 final (the Community Release). I have a
which is lazily loaded as follows (a minimal exampl
As mentioned in this link pointing to the PrimeFaces Community Forum,
We changed that part by design cause the
rowKey
attribute handling with aLazyDataModel
is not correct.
Those two methods getRowKey()
and getRowData()
need to be implemented in the associated managed bean whenever LazyDataModel<T>
is used as shown in the question.
From PrimeFaces User Guide (PDF) - (5.1 (page 164) and 5.2 (page 166)) :
Lazy Loading is an approach to deal with huge datasets efficiently, regular ajax based pagination works by rendering only a particular page but still requires all data to be loaded into memory. Lazy loading datatable renders a particular page similarly but also only loads the page data into memory not the whole dataset. In order to implement this, you’d need to bind a
org.primefaces.model.LazyDataModel
as the value and implement load method and enable lazy option. Also it is required to implementgetRowData
andgetRowKey
if you have selection enabled.
The attribute rowKey
may be used, when lazy
is disabled -- is set to false
(default) and row selection is enabled.
From PrimeFaces User Guide (PDF) - (5.1 (page 159) and 5.2 (page 161)) :
RowKey should a unique identifier from your data model and used by datatable to find the selected rows. You can either define this key by using the
rowKey
attribute or by binding a data model which implementsorg.primefaces.model.SelectableDataModel
.
Such as,
<p:dataTable var="car"
value="#{carBean.cars}"
selection="#{carBean.selectedCars}"
rowKey="#{car.id}">
<p:column selectionMode="multiple"/>
<!--columns-->
</p:dataTable>