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.