1
I’m trying to create a report, now it’s already generating, but only when I pass Jasperprint the Jremptydatasource().
JasperPrint impressoraJasper = JasperFillManager.fillReport("D:/Edital.jasper", parametros, new JREmptyDataSource());
It creates the edict but with all the null fields. So I tried to create an Array with my Bean, but I was unsuccessful, because within iReport I used 3 classes with Inner joins. And I can’t get through 3 different Bs.
In my Managedbean I have a Notice object already filled out, and my report only receives a single parameter, which is the ID of this notice. Do I really need a datasource? It is with it that I have a problem. How do I pass only this ID to Jasper and it generate my announcement?
My code:
public void imprimirRelatorio() throws IOException, ParseException {
    HashMap parametros = new HashMap();
    parametros.put("ID_EDITAL", edital.getIdEdital());
    FacesContext facesContext = FacesContext.getCurrentInstance();
    try {
        Edital[] beanArray = new Edital[1];
        beanArray[0] = edital;  
        JRBeanArrayDataSource dsColecao1 = new JRBeanArrayDataSource(beanArray, false);
       JasperPrint impressoraJasper = JasperFillManager.fillReport("D:/Edital2.jasper", parametros, dsColecao1);
        File pdf = new File("relatorio2.pdf");
        pdf.createNewFile();
        FileOutputStream arquivo = new FileOutputStream(pdf);
        System.out.println(pdf.getAbsolutePath());
        JasperExportManager.exportReportToPdfStream(impressoraJasper, arquivo);
        arquivo.flush();
        arquivo.close();  
    } catch (JRException e) {
        e.printStackTrace();
    }          
}
EDIT: I did a report that uses only one bean (without Inner joins), put that bean in an array with a single position, and it worked. Now how to put the rest of the Beans?