primefaces延迟加载未实现

时间:2013-06-03 08:14:50

标签: jsf jsf-2 primefaces

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

我的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;


}

1 个答案:

答案 0 :(得分:17)

load中有2个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 ,因此您应该覆盖第二个。