primefaces延迟加载未执行

问题描述:

我得到“java.lang.UnsupportedOperationException:延迟加载未执行。”错误。当我degub项目,lazyModel的构造函数工作,但加载方法不执行。primefaces延迟加载未执行

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

我的控制器;

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; 


} 

有2种load方法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,所以你应该重写第二个。

+2

我刚碰到同样的问题。这些方法不应该抽象吗? – Stefan

+0

我同意。如果没有提供默认实现,请让它们抽象以便开发人员知道它们必须自己提供实现。 – divinedragon