Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

primefaces lazy loading is not implemented

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;


}
like image 930
Turgut Dsfadfa Avatar asked Dec 01 '22 19:12

Turgut Dsfadfa


1 Answers

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.

like image 191
Danubian Sailor Avatar answered Feb 07 '23 13:02

Danubian Sailor