1
I’m using Demoiselle and its pagination feature, but when I need to use all the listed objects, ie, use the full return, it does not let, it keeps the pagination.
My pagination:
@Override
public LazyDataModel<NotaFiscal> getDataModel() {
if (dataModel == null) {
dataModel = new LazyDataModel<NotaFiscal>() {
@Override
public List<NotaFiscal> load(int first, int pageSize, String sortField, SortOrder sortOrder, Map<String, Object> filters) {
Pagination pagination = getPagination();
pagination.setPageSize(pageSize);
pagination.setFirstResult(first);
List<NotaFiscal> itemsList = handleResultList();
dataModel.setRowCount(pagination.getTotalResults());
return itemsList;
}
};
}
return dataModel;
}
Time when I need to use the full result, and he ends up taking only what is on the first page:
public void downloadAllPDFs() {
List<NotaFiscal> lista = handleResultList();
if (lista == null || lista.isEmpty()) {
//TODO - colocar mensagem
return;
}
List<File> files = new ArrayList<File>();
for (NotaFiscal nf : lista) {
try {
NotaFiscal nota = this.notaFiscalBC.load(nf.getId());
NotaFiscalTO notaTO = NotaFiscalToTO.geraNotaFiscalTO(nota);
extraiPDF(files, notaTO);
} catch (Exception ex) {
CriareLog.log(ex);
getMessageContext().add(getResourceBundle().getString("msg.download.erro"), SeverityType.ERROR);
return;
}
}
preparaDownloadPDF(files);
}
I wonder if there is a way to remove the pagination to use all the obtained result?
Thank you
Hello. I tried this and it didn’t work. I managed to break the branch in another way but I don’t know if it’s totally right. basically I did this: int total = getPagination(). getTotalResults(); int sizePagina = getPagination(). getpagesize(); int firstPagina = getPagination(). getFirstResult(); int curretPage = getPagination(). getCurrentPage(); getPagination(). setPageSize(total); getPagination(). setFirstResult(0); getPagination(). setCurrentPage(0); List<Notafiscal> list = handleResultList();
– Gilvan André
I see no problems. But the way I commented should work too. Which version is using?
– Saito
I’m using the 2.5.0
– Gilvan André