-1

I am using Jaspersoft studio 6.4 to create a Jasper Report. I have followed a tutorial on youtube on how to create a subreport. But unfortunately my subreport not displayed when i ran the Master report. Could some one pointed me a hint why my subreport are not displayed? Thanks..

<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="SampleReport" pageWidth="842" pageHeight="595" orientation="Landscape" columnWidth="802" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="b3d0aab2-bff8-4aaa-a77c-b315b381c78b">
<property name="com.jaspersoft.studio.data.sql.tables" value=""/>
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="New Data Adapter (3)"/>
<parameter name="ID" class="java.lang.Integer">
    <defaultValueExpression><![CDATA[1]]></defaultValueExpression>
</parameter>
<queryString language="SQL">
    <![CDATA[SELECT * FROM dbo."JasperReportTitle"
    WHERE ID = $P{ID}]]>
</queryString>
<field name="ReportTitle1" class="java.lang.String"/>
<field name="ReportTitle2" class="java.lang.String"/>
<field name="ReportTitle3" class="java.lang.String"/>
<field name="ReportTitle4" class="java.lang.String"/>
<field name="ReportTitle5" class="java.lang.String"/>
<field name="ReportTitle6" class="java.lang.String"/>
<field name="ID" class="java.lang.Integer"/>

Here is the subreport properties :

        <subreport>
            <reportElement x="1" y="10" width="799" height="60" uuid="ac703cef-cd42-4a8a-aea6-2cb039bb8c95"/>
            <subreportParameter name="ID">
                <subreportParameterExpression><![CDATA[$P{ID}]]></subreportParameterExpression>
            </subreportParameter>
            <connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
            <subreportExpression><![CDATA["SubReport.jasper"]]></subreportExpression>
        </subreport>

Here is is part of the source in 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="842" pageHeight="595" orientation="Landscape" columnWidth="802" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="135c9e7a-a78a-41f1-ba7f-9b0560e9ddd0">
<property name="com.jaspersoft.studio.data.sql.tables" value=""/>
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="New Data Adapter (3)"/>
<parameter name="ID" class="java.lang.Integer"/>
<queryString language="SQL">
    <![CDATA[SELECT * FROM dbo."JasperReportData"
    WHERE ID = $P{ID}]]>
</queryString>
<field name="Field1" class="java.lang.String"/>
<field name="Field2" class="java.lang.String"/>
<field name="Field3" class="java.lang.String"/>
<field name="Field4" class="java.lang.String"/>
<field name="Field5" class="java.lang.String"/>
<field name="Field6" class="java.lang.String"/>
<field name="Field7" class="java.lang.String"/>
<field name="Field8" class="java.lang.String"/>
<field name="ID" class="java.lang.Integer"/>
Alex K
  • 22,315
  • 19
  • 108
  • 236
  • Are you able to view subreport in case using const at subreport's query? – Alex K Sep 12 '17 at 09:11
  • if i run the subreport alone, it will display the data.no problem.but its not displayed anything when i attach it to master report – user3127287 Sep 12 '17 at 09:13
  • The same question: Are you able to view subreport in case using const at subreport's query (during call from master report)? For example: `SELECT * FROM JasperReportData WHERE ID = 1` – Alex K Sep 12 '17 at 09:15
  • yes.i am able to preview sub-report on its own however, no output seems to be generated during my attempt to preview the entire report solution – user3127287 Sep 12 '17 at 09:48
  • If you are able to build master report with subreport without parameter at query it means that parameter is missing. 1) You can add textFiled with parameter to check parameter at subreport 2) Your code for passing parameter to subreport looks well. Maybe you are using wrong subreport or using wrong connection – Alex K Sep 12 '17 at 10:03
  • I received this error ` java.lang.Integer cannot be cast to java.util.Map` when i change the subreport properties to `<![CDATA[$F{ID}]]> <![CDATA[$P{ID}]]> ` – user3127287 Sep 12 '17 at 10:51
  • You should pass $P{REPORT_PARAMETER_MAP} via `parametersMapExpression` – Alex K Sep 12 '17 at 11:55
  • Ouh..i see. But the subreport still not showing. Is it possible the data adapter could be the culprit? Im using jdbc sqljdbc4.jar. – user3127287 Sep 12 '17 at 13:06
  • `Is it possible the data adapter could be the culprit?` - I think no. The subreport & master report are working for you. Looks like you are calling subreport wrong – Alex K Sep 12 '17 at 13:16
  • finally.. i can view my subreport.seems like i install the wrong version of jre.. can refer to this thread on how to configure java build path [link](https://stackoverflow.com/questions/34613580/jaspersoft-studio-6-2-build-path-warning). – user3127287 Sep 12 '17 at 17:51

1 Answers1

0

I solved the issue by updating the JRE. I followed the step in this link https://stackoverflow.com/questions/34613580/jaspersoft-studio-6-2-build-path-warning