Jump to content
We've recently updated our Privacy Statement, available here ×

Sub report not getting displayed in the master report


shrikant_anjarlekar

Recommended Posts

Hello, I am using jasper report where I need to specify State office address based on state the customer belongs to. I have all address in a state wise csv file. I create a report to display the address using a report and passing state as a input parameter. The report work fine as a master report.

 

However when I add the same report as a sub report to a master reprot it is not displaying anything. I have gone thru all the links but of no help. I am pasting the master and child report xml's here.

MASTER.JRXML

<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.4.0.final using JasperReports Library version 6.4.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="Master" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="686a1244-29c7-455f-ae26-a6023ec3a686">
 <property name="com.jaspersoft.studio.data.defaultdataadapter" value="One Empty Record"/>
 <parameter name="CIRCLE" class="java.lang.String"/>
 <queryString>
  <![CDATA[]]>
 </queryString>
 <detail>
  <band height="500" splitType="Stretch">
   <property name="com.jaspersoft.studio.unit.height" value="pixel"/>
   <staticText>
    <reportElement x="144" y="35" width="186" height="26" uuid="a19c724d-c030-4b5b-ac74-a4e4a594d84a"/>
    <text><![CDATA[Circle Office Address]]></text>
   </staticText>
   <subreport>
    <reportElement x="3" y="5" width="550" height="20" uuid="4253e5f6-64f5-4247-9836-95c878a0ca4c">
     <property name="com.jaspersoft.studio.unit.height" value="pixel"/>
    </reportElement>
    <subreportParameter name="CIRCLE">
     <subreportParameterExpression><![CDATA[$P{CIRCLE}]]></subreportParameterExpression>
    </subreportParameter>
    <dataSourceExpression><![CDATA[new net.sf.jasperreports.engine.JREmptyDataSource()]]></dataSourceExpression>
    <subreportExpression><![CDATA["Circle_address.jasper"]]></subreportExpression>
   </subreport>
  </band>
 </detail>
</jasperReport>

SUBREPORTJRXML

<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.4.0.final using JasperReports Library version 6.4.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="Circle_address" pageWidth="595" pageHeight="842" whenNoDataType="NoDataSection" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" isTitleNewPage="true" isSummaryNewPage="true" isSummaryWithPageHeaderAndFooter="true" isFloatColumnFooter="true" isIgnorePagination="true" uuid="dd7fde1b-e0e2-4729-8a32-334ccc4c3679">
 <property name="com.jaspersoft.studio.data.defaultdataadapter" value="Circle_address_1"/>
 <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"/>
 <parameter name="CIRCLE" class="java.lang.String" isForPrompting="false">
  <defaultValueExpression><![CDATA["MH"]]></defaultValueExpression>
 </parameter>
 <queryString>
  <![CDATA[]]>
 </queryString>
 <field name="Circle" class="java.lang.String"/>
 <field name="Office" class="java.lang.String"/>
 <detail>
  <band height="12" splitType="Prevent">
   <property name="com.jaspersoft.studio.unit.height" value="pixel"/>
   <printWhenExpression><![CDATA[EQUALS($F{Circle},$P{CIRCLE})]]></printWhenExpression>
   <textField isBlankWhenNull="true">
    <reportElement isPrintRepeatedValues="false" x="-20" y="-19" width="400" height="12" isRemoveLineWhenBlank="true" uuid="a9d1f5cd-6bb0-4839-b1e3-51c7e822d724">
     <property name="com.jaspersoft.studio.unit.height" value="pixel"/>
     <property name="com.jaspersoft.studio.unit.width" value="pixel"/>
     <property name="com.jaspersoft.studio.unit.x" value="pixel"/>
     <property name="com.jaspersoft.studio.unit.y" value="pixel"/>
    </reportElement>
    <textElement>
     <font fontName="Calibri" size="8"/>
    </textElement>
    <textFieldExpression><![CDATA[$F{Office}]]></textFieldExpression>
   </textField>
  </band>
 </detail>
</jasperReport>
 

 

 

 

 

Link to comment
Share on other sites

  • Replies 4
  • Created
  • Last Reply

Top Posters In This Topic

In the master report you used a JREmptyDataSource() as datasource expression for the subreport. The subreport will come with no data, so it is nothing to be displayed. Set an appropriate expression for the subreport datasource.

Another solution: remove the datasource expression from the subreport in the master report. In the subreport set the net.sf.jasperreports.data.adapter property with the appropriate data adapter xml file.

Link to comment
Share on other sites

Agree with Shertage. 

Return variable is not required since 'Office' field is directly displayed in subreport itself. Remove the data source expression and do as Shertage's suggestion. Also, try $P{REPORT_CONNECTION} parameter in connection expression and connection type by default as 'Use a connection expression', Datasource expression as blank.

Link to comment
Share on other sites

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