Jump to content
Changes to the Jaspersoft community edition download ×

Subreport problems


grototo

Recommended Posts

Hi folks,

first of all, please excuse my bad english.

Here is my issue. I'm using JasperStudio and not IReport.

I have 2 reports, the main one (rapportppal.jrxml) and the subreport (sousrapport.jrxml).

rapportppal.jrxml

<?xml version="1.0" encoding="UTF-8"?><!-- Created with Jaspersoft Studio version 6.2.0.linagora-2-v201602221222 using JasperReports Library version 3.7.2  --><!-- 2017-05-04T16:44:07 --><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="rapportppal" pageWidth="842" pageHeight="595" orientation="Landscape" columnWidth="802" leftMargin="20" rightMargin="20" topMargin="0" bottomMargin="0">    <property name="ireport.zoom" value="1.0"/>    <property name="ireport.x" value="0"/>    <property name="ireport.y" value="0"/>    <property name="com.jaspersoft.studio.data.defaultdataadapter" value="ezcolstub"/>    <parameter name="SUBREPORT_DIR" class="java.lang.String" isForPrompting="false">        <defaultValueExpression><![CDATA["./"]]></defaultValueExpression>    </parameter>    <queryString>        <![CDATA[]]>    </queryString>    <field name="infoEntete" class="fr.gouv.finances.slm.bean.restitution.EzcolzfraoetdLigne">        <fieldDescription><![CDATA[infoEntete]]></fieldDescription>    </field>    <field name="infoEnteteDansUneListe" class="java.util.List">        <fieldDescription><![CDATA[infoEnteteDansUneListe]]></fieldDescription>    </field>    <field name="lesOperations" class="java.util.List">        <fieldDescription><![CDATA[lesOperations]]></fieldDescription>    </field>    <background>        <band splitType="Stretch"/>    </background>    <title>        <band splitType="Stretch"/>    </title>    <pageHeader>        <band height="60" splitType="Stretch">            <textField>                <reportElement x="0" y="0" width="274" height="60">                    <printWhenExpression><![CDATA[boolean.valueOf($F{infoEntete}.getLaRestitution().getTitreRestitution().toString().startsWith("SLAM - EZCOL"))]]></printWhenExpression>                </reportElement>                <textElement textAlignment="Center" verticalAlignment="Middle" lineSpacing="Single">                    <font isBold="true" pdfFontName="Helvetica-Bold"/>                </textElement>                <textFieldExpression class="java.lang.String"><![CDATA[$F{infoEntete}.getLaRestitution().getTitreRestitution()]]></textFieldExpression>            </textField>            <textField isBlankWhenNull="true">                <reportElement x="274" y="0" width="148" height="30">                    <printWhenExpression><![CDATA[boolean.valueOf($F{infoEntete}.getLaRestitution().getTitreRestitution().toString().startsWith("SLAM - EZCOL"))]]></printWhenExpression>                </reportElement>                <textElement textAlignment="Left" verticalAlignment="Middle" lineSpacing="Single">                    <font isBold="true" pdfFontName="Helvetica-Bold"/>                </textElement>                <textFieldExpression class="java.lang.String"><![CDATA["DD/DRFIP de liquidation : " + $F{infoEntete}.getLaRestitution().getLaDDFIP().getCodeDdfip()]]></textFieldExpression>            </textField>            <staticText>                <reportElement x="449" y="0" width="35" height="30">                    <printWhenExpression><![CDATA[boolean.valueOf($F{infoEntete}.getLaRestitution().getTitreRestitution().toString().startsWith("SLAM - EZCOL"))]]></printWhenExpression>                </reportElement>                <textElement textAlignment="Left" verticalAlignment="Middle" lineSpacing="Single">                    <font isBold="true" pdfFontName="Helvetica-Bold"/>                </textElement>                <text><![CDATA[PNC : ]]></text>            </staticText>            <textField isBlankWhenNull="true">                <reportElement x="484" y="0" width="50" height="30">                    <printWhenExpression><![CDATA[boolean.valueOf($F{infoEntete}.getLaRestitution().getTitreRestitution().toString().startsWith("SLAM - EZCOL"))]]></printWhenExpression>                </reportElement>                <textElement textAlignment="Left" verticalAlignment="Middle" lineSpacing="Single">                    <font isBold="true" pdfFontName="Helvetica-Bold"/>                </textElement>                <textFieldExpression class="java.lang.String"><![CDATA[$F{infoEntete}.getLaRestitution().getCodiquePosteComptable()]]></textFieldExpression>            </textField>            <staticText>                <reportElement x="534" y="0" width="100" height="30">                    <printWhenExpression><![CDATA[boolean.valueOf($F{infoEntete}.getLaRestitution().getTitreRestitution().toString().startsWith("SLAM - EZCOL"))||Boolean.valueOf($F{infoEntete}.getLaRestitution().getTitreRestitution().toString().startsWith("SLAM - EZFRA"))]]></printWhenExpression>                </reportElement>                <textElement verticalAlignment="Middle" lineSpacing="Single">                    <font isBold="true" pdfFontName="Helvetica-Bold"/>                </textElement>                <text><![CDATA[Date de production : ]]></text>            </staticText>            <textField pattern="yyyy/MM/dd/HH/mm ">                <reportElement x="634" y="0" width="124" height="30">                    <printWhenExpression><![CDATA[boolean.valueOf($F{infoEntete}.getLaRestitution().getTitreRestitution().toString().startsWith("SLAM - EZCOL"))||Boolean.valueOf($F{infoEntete}.getLaRestitution().getTitreRestitution().toString().startsWith("SLAM - EZFRA"))]]></printWhenExpression>                </reportElement>                <textElement verticalAlignment="Middle" lineSpacing="Single">                    <font isBold="true" pdfFontName="Helvetica-Bold"/>                </textElement>                <textFieldExpression class="java.util.Date"><![CDATA[new java.util.Date()]]></textFieldExpression>            </textField>            <staticText>                <reportElement x="274" y="30" width="81" height="30"/>                <textElement textAlignment="Left" verticalAlignment="Top" lineSpacing="Single">                    <font isBold="true" pdfFontName="Helvetica-Bold"/>                </textElement>                <text><![CDATA[Liquidation de :  ]]></text>            </staticText>            <textField>                <reportElement x="355" y="30" width="94" height="30"/>                <textElement verticalAlignment="Top" lineSpacing="Single">                    <font isBold="true" pdfFontName="Helvetica-Bold"/>                </textElement>                <textFieldExpression class="java.lang.String"><![CDATA[$F{infoEntete}.getLaRestitution().getExercice() +  " - " + $F{infoEntete}.getLaRestitution().getMoisSurDeuxCaracteres()]]></textFieldExpression>            </textField>            <staticText>                <reportElement x="534" y="30" width="100" height="30">                    <printWhenExpression><![CDATA[boolean.valueOf($F{infoEntete}.getLaRestitution().getTitreRestitution().toString().startsWith("SLAM - EZCOL"))||Boolean.valueOf($F{infoEntete}.getLaRestitution().getTitreRestitution().toString().startsWith("SLAM - EZFRA"))]]></printWhenExpression>                </reportElement>                <box leftPadding="0"/>                <textElement textAlignment="Left" lineSpacing="Single">                    <font isBold="true" pdfFontName="Helvetica-Bold"/>                </textElement>                <text><![CDATA[statut: définitif]]></text>            </staticText>            <textField isBlankWhenNull="false">                <reportElement x="0" y="0" width="578" height="30">                    <printWhenExpression><![CDATA[boolean.valueOf($F{infoEntete}.getLaRestitution().getTitreRestitution().toString().startsWith("SLAM - EFOETD"))]]></printWhenExpression>                </reportElement>                <box leftPadding="4"/>                <textElement textAlignment="Left" verticalAlignment="Middle" lineSpacing="Single">                    <font isBold="true" pdfFontName="Helvetica-Bold"/>                </textElement>                <textFieldExpression class="java.lang.String"><![CDATA[$F{infoEntete}.getLaRestitution().getTitreRestitution() + "        " + "DD/DRFIP : "  + $F{infoEntete}.getLaRestitution().getLaDDFIP().getCodeDdfip() +  "      "+ "Codique destinataire : " +$F{infoEntete}.getLaRestitution().getCodiquePosteComptable()]]></textFieldExpression>            </textField>            <staticText>                <reportElement x="578" y="0" width="100" height="30">                    <printWhenExpression><![CDATA[boolean.valueOf($F{infoEntete}.getLaRestitution().getTitreRestitution().toString().startsWith("SLAM - EFOETD"))]]></printWhenExpression>                </reportElement>                <textElement verticalAlignment="Middle" lineSpacing="Single">                    <font isBold="true" pdfFontName="Helvetica-Bold"/>                </textElement>                <text><![CDATA[Date de production : ]]></text>            </staticText>            <textField pattern="yyyy/MM/dd/HH/mm ">                <reportElement x="678" y="0" width="124" height="30">                    <printWhenExpression><![CDATA[boolean.valueOf($F{infoEntete}.getLaRestitution().getTitreRestitution().toString().startsWith("SLAM - EFOETD"))]]></printWhenExpression>                </reportElement>                <textElement verticalAlignment="Middle" lineSpacing="Single">                    <font isBold="true" pdfFontName="Helvetica-Bold"/>                </textElement>                <textFieldExpression class="java.util.Date"><![CDATA[new java.util.Date()]]></textFieldExpression>            </textField>            <staticText>                <reportElement x="578" y="30" width="100" height="30">                    <printWhenExpression><![CDATA[boolean.valueOf($F{infoEntete}.getLaRestitution().getTitreRestitution().toString().startsWith("SLAM - EFOETD"))]]></printWhenExpression>                </reportElement>                <box leftPadding="4"/>                <textElement textAlignment="Left" lineSpacing="Single">                    <font isBold="true" pdfFontName="Helvetica-Bold"/>                </textElement>                <text><![CDATA[statut: définitif]]></text>            </staticText>            <textField isBlankWhenNull="true">                <reportElement x="274" y="0" width="148" height="30">                    <printWhenExpression><![CDATA[boolean.valueOf($F{infoEntete}.getLaRestitution().getTitreRestitution().toString().startsWith("SLAM - EZFRA"))]]></printWhenExpression>                </reportElement>                <textElement textAlignment="Left" verticalAlignment="Middle" lineSpacing="Single">                    <font isBold="true" pdfFontName="Helvetica-Bold"/>                </textElement>                <textFieldExpression class="java.lang.String"><![CDATA["DD/DRFIP : " + $F{infoEntete}.getLaRestitution().getLaDDFIP().getCodeDdfip()]]></textFieldExpression>            </textField>        </band>    </pageHeader>    <columnHeader>        <band splitType="Stretch"/>    </columnHeader>    <detail>        <band height="100" splitType="Stretch">            <subreport>                <reportElement x="-13" y="0" width="804" height="100"/>                <parametersMapExpression><![CDATA[new HashMap($P{REPORT_PARAMETERS_MAP})]]></parametersMapExpression>                <subreportParameter name="SUBREPORT_DIR">                    <subreportParameterExpression><![CDATA[$P{SUBREPORT_DIR}]]></subreportParameterExpression>                </subreportParameter>                <dataSourceExpression><![CDATA[new JRBeanCollectionDataSource($F{lesOperations})]]></dataSourceExpression>                <subreportExpression class="java.lang.String"><![CDATA[$P{SUBREPORT_DIR} + "sousrapport.jasper"]]></subreportExpression>            </subreport>        </band>    </detail>    <pageFooter>        <band height="20" splitType="Stretch">            <textField evaluationTime="Report" isBlankWhenNull="false">                <reportElement key="textField" x="355" y="0" width="66" height="18"/>                <textElement lineSpacing="Single">                    <font size="8"/>                </textElement>                <textFieldExpression class="java.lang.String"><![CDATA["" + $V{PAGE_NUMBER} + ""]]></textFieldExpression>            </textField>            <textField isBlankWhenNull="false">                <reportElement key="textField" x="310" y="0" width="45" height="18"/>                <textElement textAlignment="Right" lineSpacing="Single">                    <font size="8"/>                </textElement>                <textFieldExpression class="java.lang.String"><![CDATA["Page " + $V{PAGE_NUMBER} + " / "]]></textFieldExpression>            </textField>        </band>    </pageFooter></jasperReport>[/code]

sousrapport.jrxml

<?xml version="1.0" encoding="UTF-8"?><!-- Created with Jaspersoft Studio version 6.2.0.linagora-2-v201602221222 using JasperReports Library version 3.7.2  --><!-- 2017-05-04T16:44:35 --><jasperReportxmlns="http://jasperreports.sourceforge.net/jasperreports"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreportshttp://jasperreports.sourceforge.net/xsd/jasperreport.xsd"name="sousrapport" pageWidth="595" pageHeight="842"whenNoDataType="AllSectionsNoDetail" columnWidth="595" leftMargin="0"rightMargin="0" topMargin="0" bottomMargin="0"isIgnorePagination="true">    <property name="com.jaspersoft.studio.unit." value="pixel"/>    <property name="com.jaspersoft.studio.unit.pageHeight" value="pixel"/>    <property name="com.jaspersoft.studio.unit.pageWidth" value="pixel"/>    <property name="com.jaspersoft.studio.unit.topMargin" value="pixel"/>    <property name="com.jaspersoft.studio.unit.bottomMargin" value="pixel"/>    <property name="com.jaspersoft.studio.unit.leftMargin" value="pixel"/>    <property name="com.jaspersoft.studio.unit.rightMargin" value="pixel"/>    <property name="com.jaspersoft.studio.unit.columnWidth" value="pixel"/>    <property name="com.jaspersoft.studio.unit.columnSpacing" value="pixel"/>    <property name="com.jaspersoft.studio.data.defaultdataadapter" value="One Empty Record"/>    <queryString>        <![CDATA[]]>    </queryString>    <field name="leBeneficiaire" class="fr.gouv.finances.slm.bean.beneficiaire.BeneficiaireDirect">        <fieldDescription><![CDATA[leBeneficiaire]]></fieldDescription>    </field>    <field name="mttAvanceAnticipee" class="java.math.BigDecimal">        <fieldDescription><![CDATA[mttAvanceAnticipee]]></fieldDescription>    </field>    <variable name="mttAvanceAnticipee1" class="java.math.BigDecimal" calculation="Sum">        <variableExpression><![CDATA[$F{mttAvanceAnticipee}]]></variableExpression>    </variable>    <group name="beneficiaire">      <groupExpression><![CDATA[$F{leBeneficiaire}.getIdentifiantCourtBeneficiaire()+$F{leBeneficiaire}.getLibelleBeneficiaire()]]></groupExpression>        <groupHeader>            <band height="40">                <frame>                    <reportElement x="0" y="0" width="81" height="40">                        <property name="local_mesure_unitheight" value="pixel"/>                        <property name="com.jaspersoft.studio.unit.height" value="px"/>                    </reportElement>                    <box>                        <leftPen lineWidth="1.0"/>                        <bottomPen lineWidth="1.0"/>                    </box>                    <textField isBlankWhenNull="false">                        <reportElement stretchType="RelativeToTallestObject" x="0" y="0" width="81" height="40">                            <property name="local_mesure_unitheight" value="pixel"/>                            <property name="com.jaspersoft.studio.unit.height" value="px"/>                        </reportElement>                        <textElement lineSpacing="Single"/>                      <textFieldExpressionclass="java.lang.String"><![CDATA[$F{leBeneficiaire}.getIdentifiantCourtBeneficiaire()]]></textFieldExpression>                    </textField>                </frame>                <frame>                    <reportElement x="80" y="0" width="474" height="40">                        <property name="local_mesure_unitheight" value="pixel"/>                        <property name="com.jaspersoft.studio.unit.height" value="px"/>                    </reportElement>                    <box>                        <leftPen lineWidth="1.0"/>                        <bottomPen lineWidth="1.0"/>                        <rightPen lineWidth="1.0"/>                    </box>                    <textField isBlankWhenNull="false">                        <reportElement x="0" y="0" width="474" height="20"/>                        <textElement lineSpacing="Single"/>                      <textFieldExpressionclass=""><![CDATA[$F{leBeneficiaire}.getLibelleBeneficiaire().concat($F{leBeneficiaire}.getSiret())]]></textFieldExpression>                    </textField>                    <textField pattern="#,#00.###;(#,#00.###-)" isBlankWhenNull="false">                        <reportElement x="0" y="20" width="474" height="20"/>                        <textElement lineSpacing="Single"/>                      <textFieldExpressionclass="java.math.BigDecimal"><![CDATA[$F{mttAvanceAnticipee}]]></textFieldExpression>                    </textField>                </frame>            </band>        </groupHeader>    </group>    <columnHeader>        <band height="40" splitType="Stretch">            <frame>                <reportElement mode="Opaque" x="0" y="0" width="80" height="40" backcolor="#39A83D">                    <property name="com.jaspersoft.studio.unit.height" value="px"/>                </reportElement>                <box leftPadding="0" bottomPadding="0">                    <topPen lineWidth="1.0"/>                    <leftPen lineWidth="1.0"/>                    <bottomPen lineWidth="1.0"/>                </box>                <staticText>                    <reportElement x="0" y="0" width="80" height="40">                        <property name="com.jaspersoft.studio.unit.height" value="px"/>                    </reportElement>                    <box>                        <topPen lineWidth="0.0"/>                    </box>                    <textElement textAlignment="Center" verticalAlignment="Middle" lineSpacing="Single"/>                    <text><![CDATA[idtSlam]]></text>                </staticText>            </frame>            <frame>              <reportElement positionType="Float" mode="Opaque" x="80" y="0"width="474" height="20" backcolor="#39A83D">                    <property name="com.jaspersoft.studio.unit.height" value="px"/>                </reportElement>                <box leftPadding="0" bottomPadding="0">                    <topPen lineWidth="1.0"/>                    <leftPen lineWidth="1.0"/>                    <bottomPen lineWidth="1.0"/>                    <rightPen lineWidth="1.0"/>                </box>                <staticText>                    <reportElement x="0" y="0" width="474" height="20">                        <property name="com.jaspersoft.studio.unit.height" value="px"/>                    </reportElement>                    <box leftPadding="2">                        <topPen lineWidth="0.0"/>                        <rightPen lineWidth="0.0"/>                    </box>                    <textElement verticalAlignment="Middle" lineSpacing="Single"/>                    <text><![CDATA[Libellé et Siret]]></text>                </staticText>            </frame>            <frame>                <reportElement mode="Opaque" x="80" y="20" width="474" height="20" backcolor="#39A83D">                    <property name="com.jaspersoft.studio.unit.height" value="px"/>                </reportElement>                <box leftPadding="0" bottomPadding="0">                    <leftPen lineWidth="1.0"/>                    <bottomPen lineWidth="1.0"/>                    <rightPen lineWidth="1.0"/>                </box>                <staticText>                    <reportElement x="0" y="0" width="474" height="20">                        <property name="local_mesure_unitheight" value="pixel"/>                        <property name="com.jaspersoft.studio.unit.height" value="px"/>                    </reportElement>                    <box leftPadding="2">                        <topPen lineWidth="0.0"/>                        <leftPen lineWidth="0.0"/>                        <bottomPen lineWidth="0.0"/>                        <rightPen lineWidth="0.0"/>                    </box>                    <textElement verticalAlignment="Middle" lineSpacing="Single"/>                    <text><![CDATA[Montant avance anticipée]]></text>                </staticText>            </frame>        </band>    </columnHeader>    <summary>        <band height="40">            <frame>                <reportElement x="0" y="0" width="81" height="40"/>                <box>                    <leftPen lineWidth="1.0"/>                    <bottomPen lineWidth="1.0"/>                </box>                <staticText>                    <reportElement x="1" y="0" width="79" height="40"/>                    <textElement textAlignment="Center" verticalAlignment="Middle" lineSpacing="Single"/>                    <text><![CDATA[TOTAL]]></text>                </staticText>            </frame>            <frame>                <reportElement x="80" y="0" width="474" height="40"/>                <box>                    <leftPen lineWidth="1.0"/>                    <bottomPen lineWidth="1.0"/>                    <rightPen lineWidth="1.0"/>                </box>                <textField pattern="#,#00.###;(#,#00.###-)" isBlankWhenNull="false">                    <reportElement key="" x="1" y="0" width="473" height="40"/>                    <textElement lineSpacing="Single"/>                  <textFieldExpressionclass="java.math.BigDecimal"><![CDATA[$V{mttAvanceAnticipee1}]]></textFieldExpression>                </textField>            </frame>        </band>    </summary></jasperReport>[/code]



I'm able to link them and execute them without problems in an Ireport programm.

But it's impossible for me when using JasperStudio.

The subreport is declared in the main one as foloowing :

Subreport expression : $P{SUBREPORT_DIR} + "sousrapport.jasper" (and my parameter SUBREPORT_DIR is declared in the main one)

Subreport parameters collection expression : new HashMap($P{REPORT_PARAMETERS_MAP})

Subreport datasource expression : new JRBeanCollectionDataSource($F{lesOperations})   (assuming I've imported the JRBeanCollectionDataSource's package)

This used to work perfectly with Ireport.

Does anyone know what I'm doing wrong?

 

Best regards,

Thomas

Link to comment
Share on other sites

  • Replies 2
  • 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...