微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

报告子报表未出现在应用程序中

如何解决报告子报表未出现在应用程序中

我有一份带有子报告的普通报告。在 iReport(3.5.1) 中两者都正确显示,但在应用程序中子报表为空白。

sub好像没有看到数据库路径。

IREPORT

Main report (cad_coraprovada.jasper): 
    Parameters:
        Name    : SUBREPORT_DIR
        Parameter Class : java.lang.String
        Default Value Expression: "C://Desenvol_java//relatoriosIReport//ARTIGOS//"             

SubReport properties:
        Subreport Expression : $P{SUBREPORT_DIR} + "cad_coraprovada_sub.jasper"
        Expression Class     : java.lang.String
        Connection type      : Use a connection expression
        Connection Expression: $P{REPORT_CONNECTION}
        Parameters : NUMERO_RECEITA  -> $F{NUMERO_RECEITA}
        
SubReport(cad_coraprovada_sub.jasper):
    Parameters 
        Name: NUMERO_RECEITA 
        Parameter Class : java.lang.Integer
        sql: Select * ... where numero_receita = $P{NUMERO_RECEITA}

Java EE

我以 PDF 格式显示报告,并且我已经对 JAVA 代码进行了大量更改以尝试传递一些参数。可能是搞砸了。

Connection con;
Dao db = new Dao();
con = db.con; 

InputStream arquivo  = FacesContext.getCurrentInstance().getExternalContext().getResourceAsstream("/cad_coraprovada.jasper");
InputStream arquivo2 = FacesContext.getCurrentInstance().getExternalContext().getResourceAsstream("/cad_coraprovada_sub.jasper");

Map<String,Object> param = new HashMap<>();
param.put("REPORT_CONNECTION",con); 

byte[] pdf = JasperRunManager.runReportToPdf(arquivo,null,ds);

JasperFillManager.fillReport(arquivo2,param,con);

HttpServletResponse res = (HttpServletResponse) FacesContext.getCurrentInstance().getExternalContext().getResponse();
res.setContentType("application/pdf");
res.setContentLength(pdf.length);
OutputStream out = res.getoutputStream();
out.write(pdf,pdf.length);
out.flush();
out.close();
FacesContext.getCurrentInstance().responseComplete();

控制台日食

注意显示的是alert,没有传递参数

DEBUG - Artigos - created for CorAprovada 
DEBUG - Artigos - filling report 
DEBUG - Artigos - adding page 1 
DEBUG - Artigos - page header 
DEBUG - Artigos - GrupoCorAprov header 
DEBUG - Artigos - creating subreport filler 
DEBUG - Artigos - created for cad_coraprovada_sub 
DEBUG - Artigos - creating subreport filler 
DEBUG - Artigos - created for cad_coraprovada_sub 
DEBUG - Artigos - starting 277731964 
DEBUG - Artigos - starting thread Thread[cad_coraprovada_sub subreport filler,5,main] 
DEBUG - Artigos - waiting for fill result 
DEBUG - Artigos - filling report 
DEBUG - Artigos - Creating sql query executer 
WARN  - Artigos - The supplied java.sql.Connection object is null. 
DEBUG - Artigos - sql query string: select codigo_artigo,codigo_cor from tbcor
                  where numero_receita = ?
DEBUG - Artigos - no data 
DEBUG - Artigos - no pages 
DEBUG - Artigos - ended 
DEBUG - Artigos - subreport 277731964 finished 

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。