问题
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