Jasper Report Not Opening Report

Asked

Viewed 43 times

0

I have a problem with a report generated by the Jasper Report. I created a screen with parameters of the report that when pressing the button calls the method below.

public void imprimir() {
    try {
        RpFolhaDePagamentoDAO dao = new RpFolhaDePagamentoDAO();
        List resultado = dao.gerarSQL(folhaDePagamento, dataInicial, dataFinal, eventosSelecionados, funcionariosSelecionados);

        JRBeanCollectionDataSource colecao = new JRBeanCollectionDataSource(resultado);

        String caminho = Faces.getRealPath("/reports/folhaDePagamento.jasper");

        Map<String, Object> parametros = new HashMap<>();
        parametros.put("dataInicial", dataInicial);
        parametros.put("dataFinal", dataFinal);

        JasperPrint relatorio = JasperFillManager.fillReport(caminho, parametros, colecao);
        byte[] buffer = JasperExportManager.exportReportToPdf(relatorio);
        Faces.sendFile(buffer, "folhaDePagamento.pdf", false);
    } catch (JRException | IOException erro) {
        String mensagemCapturada = TratadorDeErros.capturarMensagem(erro);
        Messages.addGlobalWarn("Erro ao emitir relatorio da Folha de Pagamento " + mensagemCapturada);
        erro.printStackTrace();
    }
}

At the end gives no error of execution, SQL returns me information, but is not opened the tab with the report in PDF.

I have several other reports that follow the same pattern and in this I had problem. Detail: this report was created in a new version of Eclipse and Jaspersoftstudio 6.6.0.

1 answer

0

Here is an example of the solution I gave to the method call button.

<p:commandButton title="Print" actionListener="#{rpFolhaDePagamentoBean.imprimir}" ajax="false" onclick="this.form.target='_blank'" icon="fa fa-print" />

Browser other questions tagged

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