Reputation: 1098
I am creating a JasperReports's report, which has only subreports in it.
Following is the scenario that I am currently facing.
For simplifying the question, let us consider only two jasper reports: mainReport and subReportFile1.
My Main report jasper file is as follows:
<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 5.6.1.final using JasperReports Library version 5.6.1 -->
<!-- 2015-01-28T14:21:34 -->
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="mainReport" pageWidth="555" pageHeight="802" columnWidth="555" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0" uuid="84a1df53-5934-4d37-a3ae-44735dfd5dc3">
<property name="com.jaspersoft.studio.unit." value="pixel"/>
<property name="ireport.zoom" value="1.0"/>
<property name="ireport.x" value="0"/>
<property name="ireport.y" value="1936"/>
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="One Empty Record"/>
<parameter name="SUBREPORT_DIR" class="java.lang.String" isForPrompting="false">
<defaultValueExpression><![CDATA["/my/file/path/jaspers/"]]></defaultValueExpression>
</parameter>
<parameter name="customObjectList" class="java.util.List"/>
<detail>
<band height="181" splitType="Stretch">
<subreport>
<reportElement x="0" y="3" width="554" height="157" uuid="782c39a9-1617-403c-b997-36f5cb9cdefd"/>
<dataSourceExpression><![CDATA[new net.sf.jasperreports.engine.data.JRBeanCollectionDataSource($P{malwareList})]]></dataSourceExpression>
<subreportExpression><![CDATA["/my/file/path/jaspers/subreport.jasper"]]></subreportExpression>
</subreport>
</band>
</detail>
</jasperReport>
The subreport has following fields for which I have created the following custom bean class, and send this as parameter to the main report file. I have CustomBeanClass with the following fields:
String field1;
String field2;
private int field3;
int field4;
String field5;
String date;
I am executing the following line in my java file and still I am getting a blank pdf report file.
JasperRunManager.runReportToPdfFile(path, "/home/neeraj/test.pdf",
parametersMap, new JREmptyDataSource());
Parameters map has the list which I send to the subreport. And this is what I want to do. Send the datasources of bean list to the other subreports that are present.
Where am I going wrong?
Upvotes: 0
Views: 6518
Reputation: 933
The main report contains no records (JREmptyDataSource), therefore detail band is not processed. Subreport in detail band is not executed.
Move subreport into title band. And set report property "When No Data Type" = "All Sections No Detail"
Upvotes: 2