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

0

I'm trying to pass a list by parameter to my Sub Report, however when it arrives in certain part the application stops and the report is not generated. It never goes away:

I'mpassingtheListthisway:

publicbooleangerarRelatorio(Listlist,intnumeroRelatorio,StringnomePrestador,StringdataSistema){JasperReportreport=null;InputStreamimage=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 stopped without any errors?

    
asked by anonymous 21.05.2015 / 19:54

1 answer

1

Man, this usually does not work very well, work already has a little time with jasper and it is well troubled for these parts of parameter passing, especially for objects, the tip I will give you is the following, there in jasperreports (I recommend using 5.6), in the main report you create a parameter of type list with the same name of the one that you are sending to it. At the time you set up the subreport, where you pass the directory, I believe that by parameter too, you pass the following in the "Data Source Expression" "new JRBeanCollectionDataSource (listData)" option. In this case, "dataList" is the parameter you created. Remember that it has to be identical to what you are sending in the code. Anything I can put together a little tutorial. Hope this helps. Hugs!

    
24.06.2015 / 22:23