Jump to content
We've recently updated our Privacy Statement, available here ×

SUBREPORT_DIR and Sub-SubReports


ernie

Recommended Posts

I am using iReport 2.0.0 in conjunction with JasperReports 1.3.4.

 

I have a master report, which three 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, which defaults to ".\". 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 applet that I am trying to use to generate reports. I pass a SUBREPORT_DIR parameter to JasperFillManager.fillReport(String sourceFileName, Map parameters, Connection connection). 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 it's 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?

Link to comment
Share on other sites

  • Replies 7
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

The subreport_dir parameter is a relative path, and if u set it to "" it actually means that the subreport jasper file is in the same folder as the main report. So make sure that you put the sub-report file in the same folder as the main report and pass "" as the parameter value.
Link to comment
Share on other sites

This still does not work in my case.

 

I have my .jrxml/.jasper files in one directory. When I launch iReport by double clicking on the main report file, I can generate the report, with the subreports and the one sub-subreport.

 

My Java Swing application is currently run from my Eclipse workspace project directory, so the workspace is the current directory for the JVM when my app is launched. I prompt the user for various options related to running the report, including using a JFileChooser to let the user select any JasperReport they want to run.

 

I set up my Map object with the various parameters, and include a SUBREPORT_DIR key in the Map passed to JasperFillManager.fillReport(String {full path to main .jasper report file}, Map {myMap}, Connection {mySqlConnection}). The value for the SUBREPORT_DIR is the directory where the main report is located.

 

If I remove the sub-subreport from the one subreport, everything is generated correctly, so it appears that the SUBREPORT_DIR value is being used to load the primary sub-reports. But, if my one subreport includes the sub-subreport, this SUBREPORT_DIR value is not being used or evaluated, as I get an exception stating that the sub-subreport file cannot be located, and the directory prefix for the sub-subreport is the value encoded within the subreport's .jrxml/.jasper file.

Link to comment
Share on other sites

oh okay.. i got it. from the main report to your first subreport, pass the subreport variable as a parameter expression--subreport properties-->add parameter. and i guess you'd better pass it from the first Subreport to the Second subreport too. in my case i just tried with null values for the locations in all three reports and it worked when i passed the variable from the first to the second.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...