Jump to content

Jasper SubReports Not working in Spring


arcsri

Recommended Posts

Hi,
I am new to jasper reports, I am not able figure out how to make the SubReports work. I was just trying to see how subReports works with static data, the report runs fine, but subreport is not showing up on the output. Only parent report results are showing up.

Here is my code added.

As I just have static data in my subreport, I dont pass anything to SubReportData, I am seeing blank page if I pass two JRDataSource in modelMap, If i dont pass SubReportData I am seeing only parent report.

Please help me, how to make these subReports work with spring.

Thanks.
Code:
<subreport><reportElement positionType="Float" x="140" y="76" width="200" height="100"isPrintRepeatedValues="false" isRemoveLineWhenBlank="true" backcolor="#ffcc99"/><dataSourceExpression><![CDATA[$P{SubReportData}]]></dataSourceExpression><subreportExpression class="net.sf.jasperreports.engine.JasperReport"><![CDATA[$P{PersonSubReport}]]></subreportExpression></subreport><parameter name="SubReportData" class="net.sf.jasperreports.engine.JRDataSource"/>List<Person> persons = lookUpBO.retreivePersons(); JRBeanCollectionDataSource source = new JRBeanCollectionDataSource(persons);modelMap.put("persons", source);List<> subReportList = new ArrayList<>();JRBeanCollectionDataSource subsource = new JRBeanCollectionDataSource(subReportList);modelMap.put("SubReportData", subsource);<bean id="personReportHTML" class="org.springframework.web.servlet.view.jasper reports.JasperReportsHtmlView"><property name="url" value="/WEB-INF/reports/person_jasper_template.jasper"/><property name="exporterParameters"><map><entry key="net.sf.jasperreports.engine.export.JRHtmlExpo rterParameter.IS_USING_IMAGES_TO_ALIGN"><value type="java.lang.Boolean">false</value></entry></map></property><property name="subReportUrls"><map><entry key="PersonSubReport" value="/WEB-INF/reports/personsSubReportChild.jasper"/></map></property><property name="subReportDataKeys" value="SubReportData"/><property name="reportDataKey" value="persons"/></bean>
Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...