0
votes

I am having problem with Jasper Sub Reports. I have a report template that has a subreport; in main report I have some parameters that should be available in subreport too.

Main report parameter is :

<parameter name="mainParameter" class="java.lang.Object"/>

Subreport report parameter is :

<parameter name="mainParameter" class="java.lang.Object"/>

And I provided parameters of master report for sub report like this:

<subreport isUsingCache="false">
    <reportElement x="0" y="1450" width="200" height="50" isRemoveLineWhenBlank="true"/>
    <subreportParameter name="mainParameter">
        <subreportParameterExpression><![CDATA[$P{mainParameter}]]></subreportParameterExpression>
    </subreportParameter>
    <subreportExpression class="java.lang.String"><![CDATA["subReport.jasper"]]></subreportExpression>
</subreport>

Both the JRXML's were compiling properly, no issues with that. But I'm not able to get the Sub report data in generated pdf file.

1

1 Answers

0
votes

To ensure the sub report runs/generate properly, please see that the connection from the main report is passed to the sub report. Also, the parameters which are to be used from Main Report, should be same in name and case in sub report otherwise the mapping will fail.

Please also check the relative and absolute path for the sub report from the main report. It might have so happened that path you gave for sub report is resolving to a path where the .jrxml/.jasper file is not present and therefor the sub report is not getting generated. This is a very common mistake.