guiandmag
guiandmag

Reputation: 107

SubReports in iReport

Can I have many subreports for one report on my Java Project?

I have a class that generates the main report and depending on which report the user chooses the subreport will be generated within the main report. But I do this on Java Classes, on iReport I only put the parameters. So I have only one main report and many subreports that will inserted depending on which the user will choose. Is that possible?

Upvotes: 0

Views: 165

Answers (1)

Endrik
Endrik

Reputation: 2258

A first approach might be using the printWhenExpression property on the sub/report element on your main report.
In details: you should put all your sub-reports inside the main one, set one or some parameters which are passed from your Java code to the report, and set the above mentioned property to get this parameter/parameters value. Example: <printWhenExpression><![CDATA[new Boolean($F{CONDITION}.equals("N"))]]></printWhenExpression> This, inside a subreport element, ensures that it will be printed only if the CONDITION parameter (which has it's value set from your app) is equals to N. It could be an int, char and so on.
Another option, to be considered if the whole structure changes from case to case, might be using DynamicReports (based on Jasper-Reports)

Upvotes: 1

Related Questions