muhkanda
muhkanda

Reputation: 349

Vaadin 14 Lazy Loading Grid Error on implement CallbackDataProvider

I have an error like this:

enter image description here

and here is my code :

CallbackDataProvider<AccountModel, Void> accountDataProvider = DataProvider
          .fromCallbacks(query -> accountServices.getAccountTable(
                    query.getOffset(), query.getLimit()
          ), accountServices.getAccountTableCount());

and here is the services code:

public List<AccountModel> getAccountTable(int offset, int limit) throws JsonProcessingException, EndpointException {
    List<AccountModel> datalog = new JsonResponseReader(restMockvaEndpoint.send(new EndpointRequestBuilder()
            .method("GET")
            .resource("/account")
            .property("offset", offset)
            .property("limit", limit)
            .build()
    )).getContentTable(AccountModel.class).getData();
    return datalog;
}
    
public int getAccountTableCount() throws JsonProcessingException, EndpointException {
    int datalog = new JsonResponseReader(restMockvaEndpoint.send(new EndpointRequestBuilder()
            .method("GET")
            .resource("/account")
            .build()
    )).getContentTable(AccountModel.class).getData().size();
    return datalog;
}

it's seems the error from getAccountTableCount() method that can't implement to CallbackDataProvider. Any idea?

Thank you.

Upvotes: 1

Views: 246

Answers (1)

Simon Martinelli
Simon Martinelli

Reputation: 36113

CallbackDataProvider<AccountModel, Void> accountDataProvider = 
    DataProvider
      .fromCallbacks(
          query -> accountServices.getAccountTable(
                query.getOffset(), query.getLimit()).stream(), 
        query -> accountServices.getAccountTableCount());

Upvotes: 2

Related Questions