JasperReports, Document Contains No Pages?

-1
Hello, I'm newbie to JasperReports and I'm facing a problem in order to generate my first report (a DANFE), everything I've seen on jasper so far involved database, as my application does not use bank I ignored this and I'm trying to pass the data via HashMap, everything seems to be ok, the application works perfectly, but when the report will open I get a message saying that the document does not have pages, I have already tested other JRXML layouts that I found there, none open, follow the code that loads the jasper.

private void loader(){
    try{

        JasperReport jr = JasperCompileManager.compileReport("src/jasper/teste.jrxml");
        Map dados = new HashMap();
        dados.put("Emit_CNPJ", this.nfe.getEmitente().getCnpj());
        JasperPrint jp = JasperFillManager.fillReport(jr, dados);
        JasperViewer jv = new JasperViewer(jp, false);
        jv.setTitle("DANFE");
        jv.setVisible(true);

        debug.log("DANFE carregada com sucesso.");
    }catch(JRException ex){
        debug.log("Falha ao carregar JasperReports.");
        //Logger.getLogger(Visualizer.class.getName()).log(Level.SEVERE, null, ex);
    }
}
    
asked by anonymous 02.02.2016 / 23:14

2 answers

0

What data do you want to pass to jasper, are they in a database? I have an example of how to pass parameters to jasper, but this data is in a database, just remove it:

JasperReport jasperR;
JasperPrint jasperP;
JRResultSetDataSource jrRS;
Map parametros;

rs=stmt.executeQuery("Select * from tabela");
/* implementação da interface JRDataSource para DataSource ResultSet */
jrRS = new JRResultSetDataSource( rs );// no caso, o rs seria o resultado da query.

parametros = new HashMap();
jasperR = JasperCompileManager.compileReport("report1.jrxml");
jasperP = JasperFillManager.fillReport(jasperR, parametros, jrRS);

In the last line, it has 3 parameters, the jasper report, the hash map as the second, and the result set as the last parameter. I hope I have helped you.

    
03.02.2016 / 14:37
0

Hello, I'm going back here to thank you for the answers, fortunately I've already been able to solve the problem, I do not know if it's correct, but for the time being the report is being displayed, jasper does not show the report without a DataSource, this on the line:

JasperPrint jp = JasperFillManager.fillReport(jr, dados);

I added a BeanCollection by passing an arrayList

... JasperFillManager.fillReport(jr, dados, new JRBeanCollectionDataSource(lista));

This solved the problem.

    
06.02.2016 / 14:55