flamant Posted May 20, 2012 Share Posted May 20, 2012 Hi, I definitively have some problems with subreportsHere is a master report with 2 subreports that are in a group<?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="crf" pageWidth="595" pageHeight="842" columnWidth="595" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="20"> <property name="ireport.zoom" value="1.0"/> <property name="ireport.x" value="0"/> <property name="ireport.y" value="0"/> <parameter name="SIMPLE_DATA" class="java.util.HashMap"> </parameter> <field name="subreport2" class="java.util.HashMap"/> <field name="subReportName" class="java.lang.String"/> <field name="subReportDataSource" class="net.sf.jasperreports.engine.data.JRMapCollectionDataSource"/> <field name="subReportJasperReport" class="net.sf.jasperreports.engine.JasperReport"/> <group name="Group1" > <groupExpression><![CDATA[$F{subReportName}]]></groupExpression> <groupHeader> <band height="792"> <subreport> <reportElement positionType="Float" x="0" y="0" width="555" height="792"/> <subreportParameter name="subReportName"> <subreportParameterExpression><![CDATA[$F{subReportName}]]></subreportParameterExpression> </subreportParameter> <dataSourceExpression><![CDATA[$F{subReportDataSource}]]></dataSourceExpression> <subreportExpression class="net.sf.jasperreports.engine.JasperReport"><![CDATA[$F{subReportJasperReport}]]></subreportExpression> </subreport> <subreport> <reportElement positionType="Float" x="0" y="0" width="595" height="792"/> <subreportParameter name="subReportName"> <subreportParameterExpression><![CDATA[$F{subReportName}]]></subreportParameterExpression> </subreportParameter> <dataSourceExpression><![CDATA[$F{subreport2}.get("subReportDataSource")]]></dataSourceExpression> <subreportExpression class="net.sf.jasperreports.engine.JasperReport"><![CDATA[$F{subreport2}.get("subReportJasperReport")]]></subreportExpression> </subreport> </band> </groupHeader> </group> <background> <band splitType="Stretch"/> </background> <title> <band height="0" splitType="Stretch"/> </title> <columnHeader> <band height="0" splitType="Stretch"/> </columnHeader> <detail> </detail> <columnFooter> <band height="0" splitType="Stretch"/> </columnFooter> <pageFooter> <band height="30" splitType="Stretch"> <frame> <reportElement mode="Opaque" x="2" y="0" width="553" height="30" forecolor="#D0B48E" backcolor="#F2EBDF"/> <textField> <reportElement x="224" y="3" width="39" height="20"/> <textElement textAlignment="Right"/> <textFieldExpression><![CDATA[$V{PAGE_NUMBER}+"/"]]></textFieldExpression> </textField> <textField evaluationTime="Report"> <reportElement x="264" y="3" width="40" height="20"/> <textElement/> <textFieldExpression><![CDATA["" + $V{PAGE_NUMBER}]]></textFieldExpression> </textField> </frame> </band> </pageFooter> <summary> <band height="0" splitType="Stretch"/> </summary></jasperReport> When I fill the master report as the following Map simpleMasterMap = new HashMap(); Map subreport2 = new HashMap(); subreport2.put("subReportJasperReport", subReportQueryJasperReportList.get(1)); subreport2.put("subReportDataSource", subReportQueryDataSourceList.get(1)); simpleMasterMap.put("subReportName", subReportName.get(1)); simpleMasterMap.put("subReportJasperReport", subReportJasperReport.get(1)); simpleMasterMap.put("subReportDataSource", subReportDataSource.get(1)); simpleMasterMap.put("subreport2", subreport2); simpleMasterList.add(simpleMasterMap); JRDataSource simpleDS = new JRMapCollectionDataSource(simpleMasterList); HashMap SIMPLE_DATA = new HashMap(); params.put("SIMPLE_DATA", SIMPLE_DATA); JasperPrint jasperPrint = null; InputStream jrxmlInputStream = new ByteArrayInputStream(jrxml.toString().getBytes()); if (simpleDS == null) simpleDS = new JREmptyDataSource(1); try { JasperDesign jasperDesign = JRXmlLoader.load(jrxmlInputStream); JasperReport jasperReport = JasperCompileManager.compileReport(jasperDesign); jasperPrint = JasperFillManager.fillReport(jasperReport, params, simpleDS);it loops infinitively with the following output2012-05-20 10:16:27 JRVerticalFiller [DEBUG] Fill 2: page header2012-05-20 10:16:27 JRVerticalFiller [DEBUG] Fill 2: page header2012-05-20 10:16:27 JRBaseFiller [DEBUG] Fill 2: suspeding subreport runner2012-05-20 10:16:27 JRBaseFiller [DEBUG] Fill 2: suspeding subreport runner2012-05-20 10:16:27 JRThreadSubreportRunner [DEBUG] Fill 2: notifying on suspend2012-05-20 10:16:27 JRThreadSubreportRunner [DEBUG] Fill 2: notifying on suspend2012-05-20 10:16:27 JRThreadSubreportRunner [DEBUG] Fill 2: waiting to continue2012-05-20 10:16:27 JRThreadSubreportRunner [DEBUG] Fill 2: waiting to continue2012-05-20 10:16:27 JRThreadSubreportRunner [DEBUG] Fill 2: notified of fill result2012-05-20 10:16:27 JRThreadSubreportRunner [DEBUG] Fill 2: notified of fill result2012-05-20 10:16:27 JRFillSubreport [DEBUG] Fill 1: subreport 2 to continue2012-05-20 10:16:27 JRFillSubreport [DEBUG] Fill 1: subreport 2 to continue2012-05-20 10:16:27 JRVerticalFiller [DEBUG] Fill 1: page footer2012-05-20 10:16:27 JRVerticalFiller [DEBUG] Fill 1: page footer2012-05-20 10:16:27 JRBaseFiller [DEBUG] Adding evaluation of net.sf.jasperreports.engine.fill.JRTemplatePrintText@4b939fbd by net.sf.jasperreports.engine.fill.JRFillTextField@49b9b979 for evaluation {type: REPORT, group: null, band: 0}2012-05-20 10:16:27 JRBaseFiller [DEBUG] Adding evaluation of net.sf.jasperreports.engine.fill.JRTemplatePrintText@4b939fbd by net.sf.jasperreports.engine.fill.JRFillTextField@49b9b979 for evaluation {type: REPORT, group: null, band: 0}2012-05-20 10:16:27 JRBaseFiller [DEBUG] Fill 1: adding page 53942012-05-20 10:16:27 JRBaseFiller [DEBUG] Fill 1: adding page 53942012-05-20 10:16:27 JRFillSubreport [DEBUG] Fill 1: resuming 22012-05-20 10:16:27 JRFillSubreport [DEBUG] Fill 1: resuming 22012-05-20 10:16:27 JRThreadSubreportRunner [DEBUG] Fill 2: notifying to continue2012-05-20 10:16:27 JRThreadSubreportRunner [DEBUG] Fill 2: notifying to continue2012-05-20 10:16:27 JRThreadSubreportRunner [DEBUG] Fill 2: waiting for fill result2012-05-20 10:16:27 JRThreadSubreportRunner [DEBUG] Fill 2: waiting for fill result2012-05-20 10:16:27 JRThreadSubreportRunner [DEBUG] Fill 2: notified to continue2012-05-20 10:16:27 JRThreadSubreportRunner [DEBUG] Fill 2: notified to continueThank you in advance for your answers Link to comment Share on other sites More sharing options...
sebajb Posted July 2, 2012 Share Posted July 2, 2012 <field name="subReportJasperReport" class="net.sf.jasperreports.engine.JasperReport"/>should be a parameter not a field.<parameter name="subReportJasperReport" class="net.sf.jasperreports.engine.JasperReport"/> Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now