primefaces lazy loading is not implemented

若如初见. 提交于 2020-06-12 06:14:08

问题


I am getting "java.lang.UnsupportedOperationException: Lazy loading is not implemented." error. When i degub the project, lazyModel's constructor is working but load method is not executed.

my xhtml page;

<p:dataTable id="envelopelistid" var="envelope"
                     value="#{incomingEnvelopeListController.lazyEnvelopeDataModel}"
                     selection="#{incomingEnvelopeListController.selectedEnvelope}" selectionMode="single"
                     rowKey="#{envelope.instanceIdentifier}"
                     sortMode="multiple"
                     lazy="true"
                     style="min-height: 300px"
                     paginator="true"
                     paginatorTemplate="{RowsPerPageDropdown} {FirstPageLink} {PreviousPageLink} {CurrentPageReport} {NextPageLink} {LastPageLink}"
                     rowsPerPageTemplate="5,10,15"
                     rows="10">

my controller;

private LazyDataModel<Envelope> lazyEnvelopeDataModel;

public void init(){
...
lazyEnvelopeDataModel = new LazyEnvelopeDataModel(genericService,envelope);
}

my lazy data model;

@Override
public List<Envelope> load(int first, int pageSize, String sortField, SortOrder sortOrder, Map<String, String> filters) {

    if (sortField == null) {
        sortField = "identificationId";
    }

    datasource = genericService.getByTemplate(envelopeModel, first, pageSize, new Order(sortField, Order.convertSortOrder(sortOrder.toString())));
    setRowCount((int) genericService.getCountByTemplate(envelopeModel));
    return datasource;


}

回答1:


There are 2 load methods in LazyDataModel:

public List<T> load(int first, int pageSize, String sortField, SortOrder sortOrder, Map<String,String> filters) {
    throw new UnsupportedOperationException("Lazy loading is not implemented.");
}

public List<T> load(int first, int pageSize, List<SortMeta> multiSortMeta, Map<String,String> filters) {
    throw new UnsupportedOperationException("Lazy loading is not implemented.");
}

This is where the error is thrown. You are using multisort, so you should override the second.



来源:https://stackoverflow.com/questions/16892496/primefaces-lazy-loading-is-not-implemented

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!