Why is piechart in subreport is not displayed? - jasper-reports

With the help of iReport 5.6.0 tool, I have created a master report. Then I have drag and drop a subreport to the repot group band of the master report. I have defined the SQL query and set the key and value via wizard. After that I have added a pie chart to the subreport.
When I run the subreport individually, it works fine with the provided SQL query. But when I run the master report via DynamicReports with Java code, it seems that the query does not work and return null values. As a result, no chart is displayed.
Is there any missing steps in my approach? Do I need to map/link somehow the subreport query results to master report?
Master report jrxml:
<?xml version="1.0" encoding="UTF-8"?>
<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="templatedesign2" pageWidth="595" pageHeight="842" whenNoDataType="AllSectionsNoDetail" columnWidth="575" leftMargin="10" rightMargin="10" topMargin="10" bottomMargin="10" uuid="8c9654e9-6770-46c4-a4d0-4bdf99195b70">
<parameter name="SUBREPORT_DIR" class="java.lang.String" isForPrompting="false">
<defaultValueExpression><![CDATA["D:\\DynamicReports\\src\\subreport\\"]]></defaultValueExpression>
</parameter>
<field name="item" class="java.lang.String"/>
<field name="reportTitle" class="java.lang.String"/>
<field name="customerName" class="java.lang.String"/>
<group name="Intro">
<groupHeader>
<band height="255">
<subreport isUsingCache="false">
<reportElement x="0" y="160" width="575" height="77" uuid="eb90e8b6-2860-4c94-ad10-3eb5031502fc"/>
<subreportParameter name="SUBREPORT_DIR">
<subreportParameterExpression><![CDATA[$P{SUBREPORT_DIR}]]></subreportParameterExpression>
</subreportParameter>
<dataSourceExpression><![CDATA[$P{REPORT_DATA_SOURCE}]]></dataSourceExpression>
<subreportExpression><![CDATA[$P{SUBREPORT_DIR} + "templatereport2_subreport3.jasper"]]></subreportExpression>
</subreport>
</band>
</groupHeader>
</group>
</jasperReport>
subreport jrxml:
<?xml version="1.0" encoding="UTF-8"?>
<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="templatereport2_subreport3" pageWidth="555" pageHeight="802" whenNoDataType="AllSectionsNoDetail" columnWidth="555" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0" isTitleNewPage="true" uuid="3dc0ebf2-660d-4d0c-af85-ccae1f01bdee">
<parameter name="runCycleId" class="java.lang.String"/>
<queryString>
<![CDATA[SELECT
count(status) AS count,
case when status=TRUE then 'Succeeded'else 'Failed'end AS status
FROM
"dbtable" dbtable
WHERE
id = 157
GROUP BY
status]]>
</queryString>
<field name="count" class="java.lang.Long"/>
<field name="status" class="java.lang.String"/>
<title>
<band height="351" splitType="Stretch">
<pie3DChart>
<chart evaluationTime="Report">
<reportElement x="20" y="22" width="415" height="244" uuid="a43afa44-c4e5-4ad5-b06e-8922128bcdaf"/>
<chartTitle/>
<chartSubtitle/>
<chartLegend/>
</chart>
<pieDataset>
<keyExpression><![CDATA[$F{status}]]></keyExpression>
<valueExpression><![CDATA[$F{count}]]></valueExpression>
</pieDataset>
<pie3DPlot>
<plot/>
<itemLabel/>
</pie3DPlot>
</pie3DChart>
<textField>
<reportElement x="134" y="292" width="100" height="20" uuid="2726affe-1fef-45a1-abc8-8da8c9856e42"/>
<textFieldExpression><![CDATA[$F{count}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="20" y="292" width="100" height="20" uuid="fa4e41c0-b4f4-443c-ab9e-3cf048a3f520"/>
<textFieldExpression><![CDATA[$F{status}]]></textFieldExpression>
</textField>
</band>
</title>
</jasperReport>
Can you please advise?

Since you are using a query in the subreport you should pass the connection, not the datasource to it.
<connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
In your example
<subreport isUsingCache="false">
reportElement x="0" y="160" width="575" height="77" uuid="eb90e8b6-2860-4c94-ad10-3eb5031502fc"/>
<subreportParameter name="SUBREPORT_DIR">
<subreportParameterExpression><![CDATA[$P{SUBREPORT_DIR}]]></subreportParameterExpression>
</subreportParameter>
<connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
<subreportExpression><![CDATA[$P{SUBREPORT_DIR} + "templatereport2_subreport3.jasper"]]></subreportExpression>
</subreport>

Related

New/different page for different organization IDs in Jaspersoft report

I'm looking for any suggestions on how to print a new/different page for different organization IDs. I created a jaspersoft grouping and was thinking of adding a print when expression to the organization ID group header. Would that be the way to go? Can anyone help me with the expression that I would need for that?
"Start New Page" (isStartNewPage="true") in the Appearance tab of the Properties for the Group Header is all that is necessary to start on a new page for every new group. Group Expression for your situation would simply be something like $F{organizationID}.
Here's an example that groups on $F{city}, lists $F{CustomerID} and starts a new page for every new $F{city}:
<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.20.0.final using JasperReports Library version 6.1.1 -->
<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="Blank_A4_" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="62ac07f5-f11e-4179-aedb-a42e850c1ea8">
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="northwind"/>
<queryString language="jsonql">
<![CDATA[Northwind.Customers]]>
</queryString>
<field name="City" class="java.lang.String">
<property name="net.sf.jasperreports.jsonql.field.expression" value="City"/>
<fieldDescription><![CDATA[City]]></fieldDescription>
</field>
<field name="CustomerID" class="java.lang.String">
<property name="net.sf.jasperreports.json.field.expression" value="CustomerID"/>
<fieldDescription><![CDATA[CustomerID]]></fieldDescription>
</field>
<group name="City" isStartNewPage="true">
<groupExpression><![CDATA[$F{City}]]></groupExpression>
</group>
<columnHeader>
<band height="12" splitType="Stretch">
<staticText>
<reportElement x="0" y="0" width="100" height="12" uuid="bdf3f7ab-bf1d-451e-a2ad-831a551ce388"/>
<textElement>
<font isBold="true"/>
</textElement>
<text><![CDATA[Company Name]]></text>
</staticText>
</band>
</columnHeader>
<detail>
<band height="12" splitType="Stretch">
<textField>
<reportElement x="0" y="0" width="100" height="12" uuid="c7bcc5aa-8051-48ad-a0d6-fe27c68da204"/>
<textFieldExpression><![CDATA[$F{CustomerID}]]></textFieldExpression>
</textField>
</band>
</detail>
</jasperReport>

jasperreports subreport with multiple columns does not print properly

I am new to Jasper reports. I have a master report that needs to print text in 3 columns. This text is dynamic and very long (about 2 pages). By set columnCount="3", the report is print as I expected (2 pages with 3 columns in each page). However I need to insert title on top of these 3 columns of first page only. If I just add textField on top of them. The title would be overlapped by text from 2nd column. So, I add subreport under title instead and set columnCount="3" in subreport instead. However, when I generate report this time it print everything in first column of every page. Please suggest what is wrong with my configuration. Thanks in advance.
master report
<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="Master" pageWidth="612" pageHeight="792" columnWidth="552" leftMargin="30" rightMargin="30" topMargin="0" bottomMargin="10">
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="One Empty Record"/>
<parameter name="Title"/>
<parameter name="Content"/>
<queryString>
<![CDATA[]]>
</queryString>
<background>
<band splitType="Stretch"/>
</background>
<detail>
<band height="782" splitType="Stretch">
<textField>
<reportElement x="0" y="20" width="180" height="25"/>
<textFieldExpression><![CDATA[$P{Title}]]></textFieldExpression>
</textField>
<subreport>
<reportElement x="0" y="50" width="552" height="732"/>
<subreportParameter name="Content">
<subreportParameterExpression><![CDATA[$P{Content}]]></subreportParameterExpression>
</subreportParameter>
<dataSourceExpression><![CDATA[new net.sf.jasperreports.engine.JREmptyDataSource()]]></dataSourceExpression>
<subreportExpression><![CDATA["subreport.jasper"]]></subreportExpression>
</subreport>
</detail>
</jasperReport>
subreport
<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="Subreport" pageWidth="552" pageHeight="732" columnCount="3" columnSpacing="6" columnWidth="180" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0"whenNoDataType="AllSectionsNoDetail">
<parameter name="Content"/>
<summary>
<band height="732" splitType="Stretch">
<textField textAdjust="StretchHeight">
<reportElement x="0" y="0" width="180" height="20"/>
<textFieldExpression><![CDATA[$P{Content}]]></textFieldExpression>
</textField>
</summary>
</jasperReport>

Jasper: horizontal main report causes the error "Subreport overflow on a band that does not support overflow"

I've created a report, that you can find here:
Jasper, 'print when' create white space,
StackOverflowExample.jrxml:
<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.8.0.final using JasperReports Library version 6.8.0-2ed8dfabb690ff337a5797129f2cd92902b0c87b -->
<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="StackOverflowExample" columnCount="2" pageWidth="595" pageHeight="842" columnWidth="277" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="749cd048-9a0d-4a00-89bf-1a75a4565943">
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="Sample DB"/>
<property name="com.jaspersoft.studio.data.sql.tables" value=""/>
<queryString>
<![CDATA[SELECT "ORDERS"."SHIPCOUNTRY",
Max("ORDERS"."SHIPCOUNTRY")
FROM "ORDERS"
GROUP BY "ORDERS"."SHIPCOUNTRY"
ORDER BY "ORDERS"."SHIPCOUNTRY" ASC]]>
</queryString>
<field name="SHIPCOUNTRY" class="java.lang.String">
<property name="com.jaspersoft.studio.field.label" value="SHIPCOUNTRY"/>
<property name="com.jaspersoft.studio.field.tree.path" value="ORDERS"/>
</field>
<field name="C2" class="java.lang.String">
<property name="com.jaspersoft.studio.field.label" value="C2"/>
</field>
<background>
<band splitType="Stretch"/>
</background>
<detail>
<band height="170">
<subreport>
<reportElement x="-20" y="50" width="297" height="120" isRemoveLineWhenBlank="true" uuid="4b89b974-f838-4bb7-85b6-1b0f1079c1e6">
<property name="com.jaspersoft.studio.unit.width" value="px"/>
</reportElement>
<subreportParameter name="country">
<subreportParameterExpression><![CDATA[$F{SHIPCOUNTRY}]]></subreportParameterExpression>
</subreportParameter>
<connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
<subreportExpression><![CDATA["StackOverflowExampleSubReport.jasper"]]></subreportExpression>
</subreport>
<textField>
<reportElement x="43" y="0" width="185" height="50" uuid="0c170024-70ea-492f-95fe-99ff3a27cb6d"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font size="19"/>
</textElement>
<textFieldExpression><![CDATA[$F{SHIPCOUNTRY}]]></textFieldExpression>
</textField>
</band>
</detail>
</jasperReport>
StackOverflowExampleSubReport.jrxml:
<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.8.0.final using JasperReports Library version 6.8.0-2ed8dfabb690ff337a5797129f2cd92902b0c87b -->
<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="StackOverflowExample" columnCount="2" printOrder="Horizontal" pageWidth="595" pageHeight="842" columnWidth="277" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="749cd048-9a0d-4a00-89bf-1a75a4565943">
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="Sample DB"/>
<property name="com.jaspersoft.studio.data.sql.tables" value=""/>
<parameter name="country" class="java.lang.String">
<defaultValueExpression><![CDATA["France"]]></defaultValueExpression>
</parameter>
<queryString>
<![CDATA[SELECT "ORDERS"."ORDERDATE",
"ORDERS"."FREIGHT"
FROM "ORDERS"
WHERE "ORDERS"."SHIPCOUNTRY" = $P{country}]]>
</queryString>
<field name="ORDERDATE" class="java.sql.Timestamp">
<property name="com.jaspersoft.studio.field.label" value="ORDERDATE"/>
<property name="com.jaspersoft.studio.field.tree.path" value="ORDERS"/>
</field>
<field name="FREIGHT" class="java.math.BigDecimal">
<property name="com.jaspersoft.studio.field.label" value="FREIGHT"/>
<property name="com.jaspersoft.studio.field.tree.path" value="ORDERS"/>
</field>
<background>
<band splitType="Stretch"/>
</background>
<detail>
<band height="130">
<printWhenExpression><![CDATA[new Boolean($V{REPORT_COUNT}.intValue()==1)]]></printWhenExpression>
<lineChart>
<chart evaluationTime="Report">
<reportElement isPrintRepeatedValues="false" x="0" y="3" width="235" height="125" isRemoveLineWhenBlank="true" uuid="3b5f7d89-490b-468f-9112-f606f4eda437"/>
<chartTitle/>
<chartSubtitle/>
<chartLegend/>
</chart>
<categoryDataset>
<categorySeries>
<seriesExpression><![CDATA[$P{country}]]></seriesExpression>
<categoryExpression><![CDATA[$F{ORDERDATE}]]></categoryExpression>
<valueExpression><![CDATA[$F{FREIGHT}]]></valueExpression>
</categorySeries>
</categoryDataset>
<linePlot>
<plot/>
<categoryAxisFormat>
<axisFormat labelColor="#000000" tickLabelColor="#000000" axisLineColor="#000000"/>
</categoryAxisFormat>
<valueAxisFormat>
<axisFormat labelColor="#000000" tickLabelColor="#000000" axisLineColor="#000000"/>
</valueAxisFormat>
</linePlot>
</lineChart>
</band>
</detail>
</jasperReport>
This report works, what I have is this
https://community.jaspersoft.com/sites/default/files/user_uploads/ho.hince/capture_report_test.png
The problem :
The order is vertical. What we can see is Argentina, Brazil, Austria, Canada, etc.. But I want to have Argentina, Austria, Belgium, Brazil, etc..
If I change the print order to horizontal, I get the error :
Subreport overflowed on a band that does not support overflow.
The answer Subreport overflowed on a band that does not support overflow tells that I have to use vertical, but I want it horizontal.
How can I solve it? Any ideas or tricks?
The detail band in horizontal reports is not allowed to stretch vertically, so you need to make it tall enough to fit the subreport.
In your report, the subreport element in the master report has height=120. But the subreport has detail band with height=130, plus 20 pixels top margin and 20 bottom margin. So the subreport actually takes 170 pixels in height.
If you set the height of the subreport element in the master report to 170 and the height of the master detail band to 220, it will work with horizontal print order.

How to print text for each iteration in the detail except for the last one?

I have a subreport that iterates names. I want to print a the text "or" on every loop, except for the last one. Right now I'm doing a suggested solution in this question, but it still prints in the last iterate.
Here is a sample of what I have right now:
There is still an extra or in the end of the subreport.
Current subreport source code I have right now:
<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.5.1.final using JasperReports Library version 6.5.1 -->
<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="paiwi-signatories-name-only-subreport" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="8f474d5a-0cca-4c5f-807e-71af8848276f">
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="signatoryJSON"/>
<queryString language="json">
<![CDATA[signatoryNames]]>
</queryString>
<field name="name" class="java.lang.String">
<fieldDescription><![CDATA[name]]></fieldDescription>
</field>
<field name="address" class="java.lang.String"/>
<variable name="signatoryCurrentCount" class="java.lang.Integer" resetType="None">
<variableExpression><![CDATA[$V{nameGroup_COUNT}]]></variableExpression>
</variable>
<group name="nameGroup">
<groupExpression><![CDATA[$F{name}]]></groupExpression>
</group>
<detail>
<band height="36" splitType="Stretch">
<textField isBlankWhenNull="true">
<reportElement positionType="Float" x="-20" y="-20" width="260" height="20" uuid="220a59b9-595b-4149-badd-f4a1ecff36c5"/>
<textElement>
<font fontName="Times New Roman" size="12"/>
</textElement>
<textFieldExpression><![CDATA[$F{name}]]></textFieldExpression>
</textField>
<textField evaluationTime="Auto" isBlankWhenNull="true">
<reportElement positionType="Float" x="0" y="0" width="100" height="20" isRemoveLineWhenBlank="true" uuid="afda4fcc-78fc-46f9-8c5c-2e0c4f04dfa5"/>
<textFieldExpression><![CDATA[$V{signatoryCurrentCount}.equals($V{nameGroup_COUNT}) ? "or" : ""]]></textFieldExpression>
</textField>
</band>
</detail>
</jasperReport>
How can I avoid to print the last textField after last record?
You can try a simple thing, put the 2 variables in your report, I think you already know how many pages your report will contain, and then change the printWhenExpression statement to the value of your page, for example your report contains 20 pages, then in your variable change the print condition to PAGE_NUMBER==20 and PAGE_NUMBER < 20 for the other one.
Good luck.
If you like to leverage evalutationTime="Auto"
Variables will be evaluated at a time corresponding to their reset type
From EvaluationTimeEnum
You need 2 variables with different reset time. Adapting to your example a solution can be:
Setting your signatoryCurrentCount to the REPORT_COUNT but reseting everytime your group change (hence on every record in your example)
<variable name="signatoryCurrentCount" class="java.lang.Integer" resetType="Group" resetGroup="nameGroup">
<variableExpression><![CDATA[$V{REPORT_COUNT}]]></variableExpression>
</variable>
Then you compare this with the built in variable $V{REPORT_COUNT} that have reset type report
<textFieldExpression><![CDATA[$V{signatoryCurrentCount}<$V{REPORT_COUNT} ? "or" : ""]]></textFieldExpression>
To understand the expression with reset type "Auto", the signatoryCurrentCount will have 1,2,3 (reset's at group) and $V{REPORT_COUNT} always 3 (reset at report).
Full Example
jrxml
<?xml version="1.0" encoding="UTF-8"?>
<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="paiwi-signatories-name-only-subreport" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="8f474d5a-0cca-4c5f-807e-71af8848276f">
<queryString language="json">
<![CDATA[signatoryNames]]>
</queryString>
<field name="name" class="java.lang.String">
<fieldDescription><![CDATA[name]]></fieldDescription>
</field>
<field name="address" class="java.lang.String"/>
<variable name="signatoryCurrentCount" class="java.lang.Integer" resetType="Group" resetGroup="nameGroup">
<variableExpression><![CDATA[$V{REPORT_COUNT}]]></variableExpression>
</variable>
<group name="nameGroup">
<groupExpression><![CDATA[$F{name}]]></groupExpression>
</group>
<detail>
<band height="36" splitType="Stretch">
<textField isBlankWhenNull="true">
<reportElement positionType="Float" x="-20" y="-20" width="260" height="20" uuid="220a59b9-595b-4149-badd-f4a1ecff36c5"/>
<textElement>
<font fontName="Times New Roman" size="12"/>
</textElement>
<textFieldExpression><![CDATA[$F{name}]]></textFieldExpression>
</textField>
<textField evaluationTime="Auto" isBlankWhenNull="true">
<reportElement positionType="Float" x="0" y="0" width="100" height="20" isRemoveLineWhenBlank="true" uuid="afda4fcc-78fc-46f9-8c5c-2e0c4f04dfa5"/>
<textFieldExpression><![CDATA[$V{signatoryCurrentCount}<$V{REPORT_COUNT} ? "or" : ""]]></textFieldExpression>
</textField>
</band>
</detail>
</jasperReport>
output
Do note: using evaluationTime="Auto" is resource intensive for jasper report, in most cases I would suggest that users pass in datasource the totale number of records, the report will be generated faster.

return value from sub report to main report

I have googled and prepared my sample report as per the given steps.
Steps:
Create sub report with variable retval_sub [kept default value to the variable as Hai]
Create main report variable retval_main.
Sub report properties --> added sub report variable as retval_sub and corresponding main report variable is retval_main.
I tried many times but it is not working i kept calculation type as System and Nothing also but it is not working for both.
Main report:
<?xml version="1.0" encoding="UTF-8"?>
<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="testing_ret_val" language="groovy" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="5c1d1561-8eed-47a8-89c8-3cd1946ce07a">
<parameter name="SUBREPORT_DIR" class="java.lang.String" isForPrompting="false">
<defaultValueExpression><![CDATA["E:\\ilaiyaraja\\"]]></defaultValueExpression>
</parameter>
<queryString>
<![CDATA[select * from my_table]]>
</queryString>
<field name="id" class="java.lang.Integer"/>
<variable name="retval_main" class="java.lang.String" calculation="System"/>
<detail>
<band height="43" splitType="Stretch"/>
</detail>
<summary>
<band height="226" splitType="Stretch">
<textField>
<reportElement x="31" y="173" width="100" height="20" uuid="4e5ed8fa-e4f6-42bc-8651-6888d79f01b5"/>
<textFieldExpression><![CDATA[$V{retval_main}]]></textFieldExpression>
</textField>
<subreport>
<reportElement x="15" y="16" width="200" height="100" uuid="2bd63504-b57e-4561-b527-62f6ffe46a30"/>
<connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
<returnValue subreportVariable="retval_sub" toVariable="retval_main"/>
<subreportExpression><![CDATA[$P{SUBREPORT_DIR} + "testing_ret_val_subreport1.jasper"]]></subreportExpression>
</subreport>
</band>
</summary>
</jasperReport>
Sub Report:
<?xml version="1.0" encoding="UTF-8"?>
<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="testing_ret_val_subreport1" language="groovy" pageWidth="555" pageHeight="802" columnWidth="555" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0" uuid="822d1131-8494-45f3-a9ab-39fc9a05072f">
<queryString>
<![CDATA[select id from my_table]]>
</queryString>
<field name="id" class="java.lang.Integer"/>
<variable name="retval_sub" class="java.lang.String">
<variableExpression><![CDATA["Hai"]]></variableExpression>
</variable>
<detail>
<band height="45" splitType="Stretch">
<textField>
<reportElement x="107" y="17" width="100" height="20" uuid="f8d1612a-06be-4082-b915-0df82b3faa42"/>
<textFieldExpression><![CDATA[$V{retval_sub}]]></textFieldExpression>
</textField>
</band>
</detail>
</jasperReport>
Please suggest
<subreport>
<reportElement x="-6" y="0" width="570" height="59" uuid="ac54a12b-8022-49a1-bc90-90cff664e3a1"/>
<dataSourceExpression><![CDATA[((net.sf.jasperreports.engine.data.JsonDataSource)$P{REPORT_DATA_SOURCE}).subDataSource("footer")]]></dataSourceExpression>
<subreportExpression><![CDATA["footer.jrxml"]]></subreportExpression>
</subreport>
add this to your code, it will work