4

我收到“java.lang.UnsupportedOperationException:未实现延迟加载”。错误。当我对项目进行调试时,lazyModel 的构造函数正在工作,但未执行加载方法。

我的 xhtml 页面;

<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">

我的控制器;

private LazyDataModel<Envelope> lazyEnvelopeDataModel;

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

我的惰性数据模型;

@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;


}
4

1 回答 1

18

有2load种方法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.");
}

这是引发错误的地方。您正在使用multisort,因此您应该覆盖第二个。

于 2013-06-03T08:22:03.117 回答