Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
733 views
in Technique[技术] by (71.8m points)

java - how to pass jasper file path to subreport of subreport

I am using iReport tool in conjunction with JasperReports 1.3.4.

I have a master report, which contain two subreports. One of these subreports has an embedded subreport. All of the .jasper files reside in the same directory.

iReport generated the parameter called SUBREPORT_DIR. The subreportExpression expresses the subreport filename as ![CDATA[$P{SUBREPORT_DIR} + "subreport.jasper"].

Everything works great when the report is generated from within iReport. But, I have a small Java web appplication that I am trying to use to generate reports. I pass a "SUBREPORT_DIR" parameter to JasperFillManager.fillReport(String sourceFileName, Map parameters, JRBeanCollectionDatasource). This SUBREPORT_DIR is set to the directory in which the master report is located.

fillReport throws an exception:

 net.sf.jasperreports.engine.JRException: Could not load object from location :
    .sub-subreport.jasper.

It appears that the first subreport is trying to process its subreport(embedded subreport), but the SUBREPORT_DIR is not being resolved, or used properly to generate the name of the sub-subreport.

Is there something I'm missing? How should this scenario be handled?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Click in Subreport1, go to the properties tab -> Subreport properties -> Parameters

You will pass your 'MasterReport' SUBREPORT_DIR parameter as a parameter to 'Subreport1'. Create this entry:

Name: SUBREPORT_DIR Expression: $P{SUBREPORT_DIR}

Don't forget to recompile your reports and make sure to republish your web app in the application server.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...