Jasper Subreport Null Values

Questions and answers on developing, deploying and using plugins and JavaBeans

Jasper Subreport Null Values

Postby tomasz.jarosz » Wed May 29, 2024 4:27 pm

I am creating a report in Jasper, simply passing the foundset for a datasource, where the main report has some basic information and my sub-report contains info from a relation. When I run the report through Servoy the main section is rendered normally and the sub-report static text is there but the sub-report has nulls for all of my fields. The relation does contain info so I don't know why it's not showing up.

This is how I am including my sub-report.
<dataSourceExpression><![CDATA[new net.sf.jasperreports.engine.JREmptyDataSource()]]></dataSourceExpression>
<subreportExpression><![CDATA[com.servoy.plugins.jasperreports.JasperReportsResourceLoader.loadReport("PODetails.jrxml")]]></subreportExpression>

On the subreport I defined this simple field $F{myrelation.id}

Am I missing something? Any help would be appreciated, thanks.
tomasz.jarosz
 
Posts: 5
Joined: Thu Nov 30, 2023 9:54 pm

Re: Jasper Subreport Null Values

Postby robert.edelmann » Wed May 29, 2024 5:39 pm

you pass an empty datasource as the data fro the subreport, that will not work.

You have to pass the relation to the report and define the fields / relations from the relation-foundset in the subreport.

It looks like this in our reports:
field
Code: Select all
<field name="bautagebuch_wetter_to_bautagebuch_firmen" class="net.sf.jasperreports.engine.JRDataSource"/>

subreport:
Code: Select all
<subreport>
[...]
   <dataSourceExpression><![CDATA[$F{bautagebuch_wetter_to_bautagebuch_firmen}]]></dataSourceExpression>
   <subreportExpression><![CDATA[com.servoy.plugins.jasperreports.JasperReportsResourceLoader.loadReport($P{SVY_SUBREPORT_DIR} + $P{SVY_REPORT_DIR} + "bautagebuch_vhb_komplett_anwesenheit.jrxml")]]></subreportExpression>
</subreport>
mit freundlichen Grüßen
Robert Stefan Edelmann
User avatar
robert.edelmann
 
Posts: 118
Joined: Wed Aug 14, 2013 6:12 pm

Re: Jasper Subreport Null Values

Postby tomasz.jarosz » Wed May 29, 2024 7:00 pm

tomasz.jarosz wrote:I am creating a report in Jasper, simply passing the foundset for a datasource, where the main report has some basic information and my sub-report contains info from a relation. When I run the report through Servoy the main section is rendered normally and the sub-report static text is there but the sub-report has nulls for all of my fields. The relation does contain info so I don't know why it's not showing up.

This is how I am including my sub-report.
<dataSourceExpression><![CDATA[new net.sf.jasperreports.engine.JREmptyDataSource()]]></dataSourceExpression>
<subreportExpression><![CDATA[com.servoy.plugins.jasperreports.JasperReportsResourceLoader.loadReport("PODetails.jrxml")]]></subreportExpression>

On the subreport I defined this simple field $F{myrelation.id}

Am I missing something? Any help would be appreciated, thanks.


Thanks Robert, you the man!
tomasz.jarosz
 
Posts: 5
Joined: Thu Nov 30, 2023 9:54 pm


Return to Plugins and Beans

Who is online

Users browsing this forum: No registered users and 2 guests

cron