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

Nested Subreports: How to pass a Parameter to a Sub-Sub-Report?


t3_chris

Recommended Posts

Hi!

As of my Report and Application Design i am in need to use nested SubReports. 

Think of the following structure:

ToplevelReport (My Main Report)
 

SublevelReport1 (Subreport of ToplevelReport)

SublevelReport2 (Subreport of ToplevelReport)

SubSublevelReport1  (Subreport of SublevelReport2)

 

I do want to handover the Subreports to the MainReport by  the Parameter Map, not by file (via $P{SUBREPORT_DIR} . My .jrxml Files define Subreports like this:

<subreportExpression class="net.sf.jasperreports.engine.JasperReport"><![CDATA[$P{SublevelReport2}]]></subreportExpression>

 

How do i pass the Parameter for SubSublevelReport1 to SublevelReport2? I know that i can hand over the both childs of Toplevel Report by a call like this:

 

 

Map<String, Object> parametersMainReport = new HashMap<String, Object>();

parametersMainReport.put("SublevelReport1", compiledSublevelreport1)

parametersMainReport.put("SublevelReport2", compiledSublevelreport2)

JasperPrint jasperPrint = JasperFillManager.fillReport(compiledToplevelreport, parametersMainReport);

But how can i pass SubSublevelReport1 to SublevelReport2 (which is the parent of SubSublevelReport1)?

 

I don't want to pass the Reports as Files ($P{SUBREPORT_DIR}) as my Reports are stored in a SQL Database.

 

Best Regards, 

                          christian

 

Link to comment
Share on other sites

  • Replies 3
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Just also pass your "SubSublevelReport1" as Parameter to the main Report.

There pass it to SubReport2 (in iReport it's at SubReport Properties --> Tab "Subreport other" where you can pass parameters from master to subreports)

And at SubReport2 you can use the $P{SubSublevelReport1} as SubReportExpression!

Don't forget to create the $P{SubSublevelReport1} at each level (Master/SubReport2) in the report parameters.

 

voilá thats it!

works great for me since years! :-)

regards

C-Box

Link to comment
Share on other sites

  • 8 years later...

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...