2
votes

I have a report template that has a subreport;
in main report I have some parameters that should be available in subreport too.
Main report parameter is defined like this:

<parameter name="PID" class="java.lang.Integer"/>

And in subreport I defined same parameter with the same name:

<parameter name="PID" class="java.lang.Integer"/>

And I provided parameters of master report for sub report like this: \

     <subreport>
            <reportElement x="0" y="0" width="555" height="50"/>
            <parametersMapExpression>
                 new HashMap($P{REPORT_PARAMETERS_MAP})
            </parametersMapExpression>
            <connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
            <subreportExpression class="java.lang.String"><![CDATA["subRPT.jasper"]]></subreportExpression>
     </subreport>

but this throws this:

SEVERE: null
net.sf.jasperreports.engine.JRRuntimeException: net.sf.jasperreports.engine.JRException: Incompatible java.lang.Integer value assigned to parameter PID in the subRPT dataset.
    at net.sf.jasperreports.engine.fill.JRFillSubreport.prepare(JRFillSubreport.java:711)
    at net.sf.jasperreports.engine.fill.JRFillElementContainer.prepareElements(JRFillElementContainer.java:329)
    at net.sf.jasperreports.engine.fill.JRFillBand.fill(JRFillBand.java:419)
    at net.sf.jasperreports.engine.fill.JRFillBand.fill(JRFillBand.java:378)
    at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillColumnBand(JRVerticalFiller.java:2035)
    at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillDetail(JRVerticalFiller.java:760)
    at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReportStart(JRVerticalFiller.java:270)
    at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:128)
    at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:946)
    at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:845)
    at net.sf.jasperreports.engine.fill.JRFiller.fillReport(JRFiller.java:58)
    at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:417)
    at biorec.control.reporting$1.doInBackground(reporting.java:177)

What is the problem?

Thanks

3

3 Answers

1
votes

First save subreport JRXML in Jasper server then save same subreport in desktop which you want to use and then drag Subreport element from palette .

Step 1:-

    Select "Use an existing report" option and select the same subreport 

next

     it will ask for database, if you are using the same database 

then click Next button

    then it will ask for parameters , select all the parameter expression 

and next

  choose "Store the directory name in  a parameter" option 

then finish .

Now select the subreport then go to the property tab and It won't run in Ireport and select "Subreport Expression" , there you have to give the path of your subreport which is in Jasperserver in this

 format "repo:/path_of_subreport in jasper".
1
votes
<subreportParameter name="PID">
    <subreportParameterExpression>
        <![CDATA[$P{PID}]]> 
    </subreportParameterExpression>
</subreportParameter>
0
votes

Thnak you all,
But the problem was in version miss-matching between my JasperReport library and iReport.
using same versions fixed the problem.