Application for when I pass a List per parameter to a Sub report

Asked

Viewed 288 times

0

I am trying to pass a List by parameter to my Sub Report, but when it arrives in a certain part the application to and the report is not generated. Never get out of it:

inserir a descrição da imagem aqui

I’m passing the list that way:

public boolean gerarRelatorio(List list, int numeroRelatorio, String nomePrestador, String dataSistema) {
    JasperReport report = null;
    InputStream image = this.getClass().getResourceAsStream("/br/com/xml/relatorio/LOGO.png");
    filtro.put("Image", image);

    filtro.put("listaDados", listaProcedimentos);
    filtro.put("localizarRel", "src/br/com/xml/relatorio/subRelatorio.jasper");

    try {

        InputStream inputStreamReal = getClass().getResourceAsStream("/br/com/xml/relatorio/Relatorio3.jrxml");
        report = JasperCompileManager.compileReport(inputStreamReal);
    } catch (JRException ex) {
        Logger.getLogger(frmPegaXml.class.getName()).log(Level.SEVERE, null, ex);
        JOptionPane.showMessageDialog(null, "Erro ao pegar arquivos!", "ERRO!", JOptionPane.ERROR_MESSAGE);
    }
    try {

        JasperPrint print = JasperFillManager.fillReport(report, filtro, new JRBeanCollectionDataSource(list));
        JasperExportManager.exportReportToPdfFile(print,
                "C:/Demonstrativos/" + dataSistema + "/" + nomePrestador + "_" + dataSistema + "_" + numeroRelatorio + ".pdf");

        return true;

    } catch (JRException ex) {
        Logger.getLogger(frmPegaXml.class.getName()).log(Level.SEVERE, null, ex);
        JOptionPane.showMessageDialog(null, "Erro ao Gerar relatório, verifique se nenhum arquivo está aberto ou se o nome está correto!\n" + ex, "ERRO!", JOptionPane.ERROR_MESSAGE);
        return false;
    }
}

Does anyone know why the application stops without any errors?

1 answer

1

Dude, this usually doesn’t work very well, work already has a little time with Jasper and he is very troublesome for these parts of parameter passage, mainly for objects, the tip I’ll give you is the following, there in jasperreports(I recommend using the 5.6), in the main report you create a list type parameter with the same name as the one you are sending to it. When you go to configure the subreport, where you pass the directory, I believe that by parameter also, you pass the following in the option "Data Source Expression" "new Jrbeancollectiondatasource(listed)". In this case, "datalist" is the parameter you created. Remember that it has to be identical to the one you are sending in the code. Anything I can put together a little tutorial. I hope I helped. Hug!

Browser other questions tagged

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