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.