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

Pass datasource as paramater to sub-report


gnpc22

Recommended Posts

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
Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

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