We are using the open source framework JasperReports to creating PDF reports.
One of my Team members wanted to create a MasterReport with a SubReport. The SubReport was nothing special, it included just static Text.The problem was, that the subreport was not rendered, it was always empty.
The problem was that the subreport need to have a data connection. Even you don’t need one. The solution is to include a empty DataSource like this:
<dataSourceExpression><![CDATA[new net.sf.jasperreports.engine.JREmptyDataSource()]]></dataSourceExpression>
The sub report definition in the master report looks like this:
<subreport>
<reportElement x="0" y="246" width="504" height="100"/>
<subreportParameter name="nameLabel"/>
<dataSourceExpression><![CDATA[new net.sf.jasperreports.engine.JREmptyDataSource()]]></dataSourceExpression>
<subreportExpression><![CDATA[$P{SUBREPORT_DIR}]]></subreportExpression>
</subreport>