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

问题描述

我有一份带有子报告的普通报告。在 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 (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...