0

I am developing an app to view emails. The inbox is often very large and I want to use LazyDataModel to extract them by parts. Data extraction works, but the init() function apparently first renders and then extracts them.

Bean:

@PostConstruct
public void init() {
    JwmaSession jession = (JwmaSession) getfromSession("jession");
    listaCorreosEntrada = new LazyCorreoDataModel(jession);
    System.out.println("Rows number: " + listaCorreosEntrada.getRowCount());
}

LazyCorreoDataModel:

@Override
public List<Correo> load(int first, int pageSize, String sortField, SortOrder sortOrder, Map<String, Object> filters) {
List<Correo> messageList = new ArrayList<Correo>();
    try {
        Store store = jession.store;
        jFolder = new JwmaFolder(store, "INBOX");
        messageList = jFolder.messageList(false, first, pageSize);
    } catch (final Exception e) {
        e.printStackTrace();
    }
    System.out.println("List size: " + messageList.size());
    return messageList;
}

At the time of executing this code, the result is:

Rows number: 0
List size: 10

I have not used LazyDataModel much, but I think it should be the other way around.

Alex Cba
  • 16
  • 2
  • 2
    Possible duplicate of [How to query data for Primefaces dataTable using lazy loading and pagination](https://stackoverflow.com/questions/13972193/how-to-query-data-for-primefaces-datatable-using-lazy-loading-and-pagination) – perissf Aug 19 '17 at 17:38
  • You must invoke `setRowCount` as explained in the accepted answer of the duplicate question – perissf Aug 19 '17 at 17:40
  • Many thanks @perissf, indeed missing: `this.setRowCount(messageList.size());` And implement `@Override getRowKey ()` function. – Alex Cba Aug 19 '17 at 18:02

0 Answers0