Jasper Report Report Not Opening

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();
    }
}

In the end it does not give execution error, SQL returns me information, but it does not open 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.

    
asked by anonymous 24.09.2018 / 18:03

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" />
    
27.09.2018 / 20:11