Subreports
Subreports are used to insert a report within an existing report. Subreports are similar to reports. They both use a query language and contain fields, parameters, and variables. Subreports should not have margins. From the perspective of the parent report, a subreport is simply a link to another JRXML file.
After you create a subreport, you must insert it into the parent report using Jaspersoft Studio Professional. When you are connecting a subreport to its parent report, you must select the Subreport tab and provide the Expression field information. The expression is used to identify the data source and file name of a subreport. The name of the subreport in the subreport expression must match the name assigned to the report when it was added to NexJ Admin Console. It should be in the following form:
((nexj.core.reporting.jasper.DataSource) $P{REPORT_DATA_SOURCE}).loadSubReport ("SUBREPORT_NAME")
Info
In the subreport expression, SUBREPORT_NAME
must match the name assigned to the JRXML file when it is loaded into the database from NexJ Admin Console. For more information, see Adding subreports in NexJ Admin Console.
You will then click Parameters and define the following parameters:
NEXJ_ASSOCIATION
The subreport association path relative to the parent report class.
NEXJ_PARENT
The parent instance. The $F{:instance}
is built in.
NEXJ_LAZY
To specify that the subreport query is separate from the parent report query, set the parameter to TRUE
. The default is FALSE
. If you omit the parameter, then it is assumed to be FALSE
, which means that the subreport query is a subcollection of the parent report query.
NEXJ_REPOSITORY
The metadata object. The value is passed into the master report and must be manually passed into the subreport.
NEXJ_REPORT_CACHE
This cache contains both subreports, as well as the result of the parent report query. If this parameter is missing, each subreport definition will be loaded for each master instance. Otherwise, the definitions are cached. Also, if this parameter is missing, any attributes loaded by the parent report query will need to be reloaded by the subreport query. Otherwise, the attribute values are loaded from the cache.
REPORT_RESOURCE_BUNDLE
The custom NexJ string loader object. The value is passed into the master report and must be manually passed into the subreport.
REPORT_LOCALE
The report locale. The value is passed into the master report and must be manually passed into the subreport. The SysReportCommand'localeName
is used to initialize the value.
REPORT_TIME_ZONE
The time zone. The value is passed into the master report and must be manually passed into the subreport.
Info
The parameters that are prefixed with NEXJ_do not need to be defined explicitly in the parent report because the NexJ Framework passes values from the model to these parameters automatically.
The following parameters show an example:
<subreportParameter name="NEXJ_ASSOCIATION"> <subreportParameterExpression><![CDATA["addresses"]]></subreportParameterExpression> </subreportParameter> <subreportParameter name="NEXJ_PARENT"> <subreportParameterExpression><![CDATA[$F{:instance}]]></subreportParameterExpression> </subreportParameter> <subreportParameter name="NEXJ_LAZY"> <subreportParameterExpression><![CDATA[Boolean.TRUE]]></subreportParameterExpression> </subreportParameter> <subreportParameter name="NEXJ_REPOSITORY"> <subreportParameterExpression><![CDATA[$P{NEXJ_REPOSITORY}]]></subreportParameterExpression> </subreportParameter> <subreportParameter name="NEXJ_REPORT_CACHE"> <subreportParameterExpression><![CDATA[$P{NEXJ_REPORT_CACHE}]]></subreportParameterExpression> </subreportParameter> <subreportParameter name="REPORT_RESOURCE_BUNDLE"> <subreportParameterExpression><![CDATA[$P{REPORT_RESOURCE_BUNDLE}]]></subreportParameterExpression> </subreportParameter> <subreportParameter name="REPORT_LOCALE"> <subreportParameterExpression><![CDATA[$P{REPORT_LOCALE}]]></subreportParameterExpression> </subreportParameter>\ <subreportParameter name="REPORT_TIME_ZONE"> <subreportParameterExpression><![CDATA[$P{REPORT_TIME_ZONE}]]></subreportParameterExpression> </subreportParameter>
Adding subreports in NexJ Admin Console
Loading subreports into NexJ Admin Console will generate and link them to the parent report using the subreport expression. NexJ Admin Console can be used to update the parent report and subreports using the Report Manager screen.
To add a subreport in NexJ Admin Console:
Your subreport is now connected to the parent report.