Jump to content
Changes to the Jaspersoft community edition download ×

subreports with JRBeanCollectionDataSource


2005 IR Help

Recommended Posts

By: Wex - wexwarez

subreports with JRBeanCollectionDataSource

2004-11-23 18:17

I was wondering if there is a way to create a subreport using a bean data source. I have an Invoice report which uses a bean data source to convey claims. Each claim can have one or more payments. What I would like to do is have my ClaimBean have a payments property that I can pass to a payment subreport. I envision the payments property as a list but it could be an array.

thanks

-ryan

 

 

 

 

By: massimiliano - miramassi

RE: subreports with JRBeanCollectionDataSource

2004-11-24 01:24

Yes, it's possible. I've been working on it recently and this is the way I got it:

 

MasterReport:

.

.

<field name="payments" class="java.lang.Object"/>

<!--I suppose your master bean has has a method getPayments which returns an ArrayList or something similar-->

.

.

<subreport isUsingCache="true">

<reportElement ../>

<dataSourceExpression><![CDATA[new net.sf.jasperreports.engine.data.JRBeanCollectionDataSource((java.util.Collection)$F{payments})]]></dataSourceExpression>

<subreportExpression ...></subreportExpression>

</subreport>

.

.

.

 

In subreport you can call child bean properties as usual when using JRBeanCollectionDataSource as data source.

 

I hope this was what you needed.

 

Bye.

 

 

 

 

By: Wex - wexwarez

RE: subreports with JRBeanCollectionDataSourc

2004-11-24 16:48

Thanks, this makes sense, you just convert it to a collection in a jrbeancollectiondatasource and bang you are good to go. I only use JRBeanCollectionDataSources in my jasperreports cause I find them to be so much cleaner than putting the sql directly into the report code. So this is great it means there are no limits i will have to try.

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