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

前端 未结 1 1770
鱼传尺愫
鱼传尺愫 2021-01-17 16:13

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

相关标签:
1条回答
  • 2021-01-17 16:41

    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>
    
    0 讨论(0)
提交回复
热议问题