Jump to content
Changes to the Jaspersoft community edition download ×

jasperreport issue : subreports empty if one has no data


matt...
Go to solution Solved by matt...,

Recommended Posts

Hi all,
 
I'm using a report made of 4 subreports. All is fine if the subreports have data.
 
My problem is when one of the subreport has no data in it, all the next subreports have no data either (even if they should have). Just switching the empty subreport in the last position makes the other ones appears correctly.
 
I'm pretty sure I'm missing a parameter in the main report but I don't know which one.
 
Could someone help me one this please ?
 
Here is the code of the main report :
 
<?xml version="1.0" encoding="UTF-8"?><!-- Created with Jaspersoft Studio version 5.6.2.final using JasperReports Library version 5.6.1  --><!-- 2015-01-08T10:42:45 --><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="main" language="groovy" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" isSummaryWithPageHeaderAndFooter="true" whenResourceMissingType="Error" uuid="c8f51062-ef27-462e-9de5-1896e168297e">       <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="One Empty Record"/>    <property name="com.jaspersoft.studio.unit." value="pixel"/>    <property name="com.jaspersoft.studio.unit.pageHeight" value="cm"/>    <property name="com.jaspersoft.studio.unit.pageWidth" value="cm"/>       <parameter name="SUB_ANO_DATASOURCE" class="net.sf.jasperreports.engine.data.JRBeanCollectionDataSource" isForPrompting="false"/>    <parameter name="SUB_COMP_DATASOURCE" class="net.sf.jasperreports.engine.data.JRBeanCollectionDataSource" isForPrompting="false"/>    <parameter name="SUB_REF_DATASOURCE" class="net.sf.jasperreports.engine.data.JRBeanCollectionDataSource" isForPrompting="false"/>    <parameter name="SUB_EVE_DATASOURCE" class="net.sf.jasperreports.engine.data.JRBeanCollectionDataSource" isForPrompting="false"/>       <parameter name="REPORT_DIR" class="java.lang.String">        <defaultValueExpression>            <![CDATA["U:\Bureau\JASPER\"]]>        </defaultValueExpression>    </parameter>    <parameter name="IMAGES_DIR" class="java.lang.String"/>    <queryString>        <![CDATA[select * from compteurcomposante]]>    </queryString>    <background>        <band splitType="Stretch"/>    </background>    <pageHeader>        <band height="142">            <textField>                <reportElement x="20" y="70" width="236" height="20" isRemoveLineWhenBlank="true" isPrintInFirstWholeBand="true" uuid="65155034-8089-4d01-85d6-d31caab280a7"/>                <textFieldExpression>                    <![CDATA["Nom : "+$P{REPORT_PARAMETERS_MAP}.get("nom")]]>                </textFieldExpression>            </textField>            <textField>                <reportElement x="150" y="20" width="279" height="20" uuid="b1f81e3c-637d-4713-8e0c-c09453d00f15"/>                <textElement>                    <font size="10"/>                </textElement>                <textFieldExpression>                    <![CDATA["FICHE HORAIRE ENSEIGNANT AU : "+$P{REPORT_PARAMETERS_MAP}.get("date")]]>                </textFieldExpression>            </textField>            <textField>                <reportElement x="20" y="110" width="235" height="20" isRemoveLineWhenBlank="true" uuid="8bdf4b80-6ce1-40de-a6b1-a67987fd9af9">                    <printWhenExpression>                        <![CDATA[$P{REPORT_PARAMETERS_MAP}.containsKey("rattachement")]]>                    </printWhenExpression>                </reportElement>                <textFieldExpression>                    <![CDATA["Rattachement : "+$P{REPORT_PARAMETERS_MAP}.get("rattachement")]]>                </textFieldExpression>            </textField>            <textField>                <reportElement x="20" y="90" width="235" height="20" isRemoveLineWhenBlank="true" uuid="9c6cc5c8-79f9-48b3-8a47-219504e109d5">                    <printWhenExpression>                        <![CDATA[$P{REPORT_PARAMETERS_MAP}.containsKey("grade")]]>                    </printWhenExpression>                </reportElement>                <textFieldExpression>                    <![CDATA["Grade : "+ $P{REPORT_PARAMETERS_MAP}.get("grade")]]>                </textFieldExpression>            </textField>            <image hAlign="Right" onErrorType="Blank">                <reportElement mode="Transparent" x="390" y="0" width="164" height="61" uuid="1d1765bf-f25f-44b5-b871-7bb1109a19a4"/>                <imageExpression>                    <![CDATA[$P{IMAGES_DIR}+"logo.jpg"]]>                </imageExpression>            </image>        </band>    </pageHeader>    <detail>        <band>            <property name="com.jaspersoft.studio.layout" value="com.jaspersoft.studio.editor.layout.VerticalRowLayout"/>            <property name="local_mesure_unitheight" value="pixel"/>            <property name="com.jaspersoft.studio.unit.height" value="px"/>            <printWhenExpression>                <![CDATA[$P{SUB_COMP_DATASOURCE}.getRecordCount()!=0]]>            </printWhenExpression>            <subreport runToBottom="false">                <reportElement positionType="Float" isPrintRepeatedValues="false" mode="Opaque" x="0" y="0" width="555" height="0" uuid="b3ff7327-b224-4449-9528-a86869a771bf">                    <property name="local_mesure_unitheight" value="pixel"/>                    <property name="com.jaspersoft.studio.unit.height" value="px"/>                </reportElement>                <subreportParameter name="SUBREPORT_DIR"/>                <dataSourceExpression>                    <![CDATA[$P{REPORT_PARAMETERS_MAP}.get("SUB_COMP_DATASOURCE")]]>                </dataSourceExpression>                <subreportExpression>                    <![CDATA[$P{REPORT_DIR} + "subCompteurPdf.jasper"]]>                </subreportExpression>            </subreport>        </band>        <band>            <property name="local_mesure_unitheight" value="pixel"/>            <property name="com.jaspersoft.studio.unit.height" value="px"/>            <property name="com.jaspersoft.studio.layout" value="com.jaspersoft.studio.editor.layout.VerticalRowLayout"/>            <printWhenExpression>                <![CDATA[$P{SUB_EVE_DATASOURCE}.getRecordCount()!=0]]>            </printWhenExpression>            <subreport runToBottom="false">                <reportElement positionType="Float" isPrintRepeatedValues="false" mode="Opaque" x="0" y="0" width="555" height="0" uuid="a38cd8ce-92fe-4089-8295-c61fb6bbc618">                    <property name="local_mesure_unitheight" value="pixel"/>                    <property name="com.jaspersoft.studio.unit.height" value="px"/>                </reportElement>                <dataSourceExpression>                    <![CDATA[$P{REPORT_PARAMETERS_MAP}.get("SUB_REF_DATASOURCE")]]>                </dataSourceExpression>                <subreportExpression>                    <![CDATA[$P{REPORT_DIR} + "subReferentielPdf.jasper"]]>                </subreportExpression>            </subreport>        </band>        <band>            <property name="local_mesure_unitheight" value="pixel"/>            <property name="com.jaspersoft.studio.unit.height" value="px"/>            <property name="com.jaspersoft.studio.layout" value="com.jaspersoft.studio.editor.layout.VerticalRowLayout"/>            <printWhenExpression>                <![CDATA[$P{SUB_REF_DATASOURCE}.getRecordCount()!=0]]>            </printWhenExpression>            <subreport runToBottom="false">                <reportElement positionType="Float" isPrintRepeatedValues="false" mode="Opaque" x="0" y="0" width="555" height="0" isPrintInFirstWholeBand="true" uuid="dbd4c541-157c-48f2-b8e0-ff83d60fe7d4">                    <property name="com.jaspersoft.studio.unit.height" value="px"/>                    <property name="local_mesure_unitheight" value="pixel"/>                </reportElement>                <dataSourceExpression>                    <![CDATA[$P{REPORT_PARAMETERS_MAP}.get("SUB_EVE_DATASOURCE")]]></dataSourceExpression>                <subreportExpression>                    <![CDATA[$P{REPORT_DIR} + "subEvePdf.jasper"]]>                </subreportExpression>            </subreport>        </band>        <band>            <property name="local_mesure_unitheight" value="pixel"/>            <property name="com.jaspersoft.studio.unit.height" value="px"/>            <property name="com.jaspersoft.studio.layout" value="com.jaspersoft.studio.editor.layout.VerticalRowLayout"/>            <printWhenExpression>                <![CDATA[$P{SUB_ANO_DATASOURCE}.getRecordCount()!=0]]>            </printWhenExpression>            <subreport runToBottom="false">                <reportElement positionType="Float" isPrintRepeatedValues="false" mode="Opaque" x="0" y="0" width="555" height="0" isPrintInFirstWholeBand="true" uuid="097a58b6-3487-4e70-b576-6f2c08898290">                    <property name="local_mesure_unitheight" value="pixel"/>                    <property name="com.jaspersoft.studio.unit.height" value="px"/>                </reportElement>                <dataSourceExpression>                    <![CDATA[$P{REPORT_PARAMETERS_MAP}.get("SUB_ANO_DATASOURCE")]]>                </dataSourceExpression>                <subreportExpression>                    <![CDATA[$P{REPORT_DIR} + "subAnomaliesPdf.jasper"]]>                </subreportExpression>            </subreport>        </band>    </detail>    <pageFooter>        <band height="51" splitType="Immediate">            <staticText>                <reportElement x="178" y="0" width="199" height="51" uuid="c36004e8-d2e4-4224-9c6e-b2bfca7eea69"/>                <textElement textAlignment="Center"/>                <text>                    <![CDATA[signature de l'enseignant]]>                </text>            </staticText>            <textField>                <reportElement x="480" y="0" width="50" height="51" uuid="3a6bca9f-2254-4005-9763-8f6a0971d01c">                    <property name="local_mesure_unitheight" value="pixel"/>                    <property name="com.jaspersoft.studio.unit.height" value="px"/>                    <property name="local_mesure_unitwidth" value="pixel"/>                    <property name="com.jaspersoft.studio.unit.width" value="px"/>                </reportElement>                <textElement textAlignment="Right" verticalAlignment="Bottom"/>                <textFieldExpression>                    <![CDATA[$V{PAGE_NUMBER}]]>                </textFieldExpression>            </textField>            <textField evaluationTime="Report">                <reportElement x="530" y="0" width="24" height="51" uuid="2023aa5f-45b4-4746-8a31-7507cd5a616d">                    <property name="com.jaspersoft.studio.unit.height" value="px"/>                    <property name="com.jaspersoft.studio.unit.width" value="px"/>                    <property name="local_mesure_unity" value="pixel"/>                    <property name="com.jaspersoft.studio.unit.y" value="px"/>                </reportElement>                <textElement textAlignment="Left" verticalAlignment="Bottom"/>                <textFieldExpression>                    <![CDATA[" / "+$V{PAGE_NUMBER}]]>                </textFieldExpression>            </textField>        </band>    </pageFooter></jasperReport>[/code]

sorry the xml code doesn't seem to be formated the proper way, it's been inserted in a xml code section though (I'll try to change that)

Link to comment
Share on other sites

  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

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...