Remove pagination from Demoiselle

Asked

Viewed 65 times

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

1 answer

2

On the line:

List<NotaFiscal> lista = handleResultList();

Use:

List<NotaFiscal> lista = getResultList();
  • 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();

  • I see no problems. But the way I commented should work too. Which version is using?

  • I’m using the 2.5.0

Browser other questions tagged

You are not signed in. Login or sign up in order to post.