java.lang.UnsupportedOperationException: getRowData(String rowKey) must be implemented when basic rowKey algorithm is not used

点点圈 提交于 2019-12-01 15:53:11

As mentioned in this link pointing to the PrimeFaces Community Forum,

We changed that part by design cause the rowKey attribute handling with a LazyDataModel 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 implement getRowData and getRowKey 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 implements org.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>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!