Pass datasource as paramater to sub-report

0

I'm making a "Java bridge" between a REST WebService request and a jasper report, and I was wondering if it's possible to pass a Datasource as a parameter to a sub-report?

I used the following tutorial www.richardnichols.net/2010/02/simple-guide-to-sub-reports-in-jasperreports-ireport/ to pass a Java datasource into a Jasper sub-report and everything worked fine. My problem is that the client that invokes the WebService doesn't know the format of the Jasper report and vice-versa.

The problem is that the sub-report may contain another sub-report and so on, and accordingly to the tutorial I would have to create a class structure of the data passed from the client and convert it to a net.sf.jasperreports.engine.data.JRBeanCollectionDataSource(....) that the report could consume it, so I would have a net.sf.jasperreports.engine.data.JRBeanCollectionDataSource inside a net.sf.jasperreports.engine.data.JRBeanCollectionDataSource, but I don't know the format of the reports (and sub-reports) because they are changed by the client.

So I was trying to make the datasource available from the parameters, and by this way The client could just pass the ones required by each of the sub reports, is it even possible to do this?

 

I tried defining a parameter in the sub-report as:

    <parameter name="subReportParameter" class="java.util.List"/>

and I'm passing the parameter to the sub-report as:

    <subreportParameter name="subReportParameter">
        <subreportParameterExpression><![CDATA[$F{addresses}.type]]></subreportParameterExpression>
    </subreportParameter>

But when I put:

    <textField>
        <reportElement x="254" y="33" width="288" height="20"/>
        <textElement/>
        <textFieldExpression><![CDATA[$P{subReportParameter}]]></textFieldExpression>
    </textField>

into the Detail Band, I get [Value1, Value2, ....., Value999] instead of the desired list, what am I missing here?

 

Thanks in advance for any help provided ;)

 



Post Edited by gnpc22 at 05/14/2012 16:31
gnpc22's picture
1
Joined: May 14 2012 - 8:55am
Last seen: 6 years 8 months ago

0 Answers:

No answers yet
Feedback
randomness