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

how to add Javabean set datasource as subreport


atmaling

Recommended Posts

Hi ,

               I am new in Ireport I made one report which have JavaBean Datasource connection now I want to add this report as a subreport into another report which may have different connection .

               I made that and write conection expression is P!{Report connection} it runs fine but data is not display.

Please help me how to solve that problem

                         Please it is urgent for me

                                                                                                                                                                                Thanking You

                                                                                                                                                                              Atmaling

 

 

 

Link to comment
Share on other sites

  • Replies 5
  • Created
  • Last Reply

Top Posters In This Topic


Hi,I'm not properly able with english...

My english is too scholastic , my iReport version is old (2.0) and also in Italian language...

Anyway I try to help you...

 I met in this period  your same issue and i solved with theese following steps.

First of all we have to know that datasources are "consumable" objects, so we can use them only once a time.

This is important ,for example,when we must to print multiple report  in different formats.

I think  that your problem depends by this matter, but I'm a newbe and I'm not sure.

1- I have set  theese subrpt properties (in the main rpt  => rightclick on subrpt icon):

"new JRBeanCollectionDataSource($F{fieldSubDataSource})"  => Expression of data source (nb: note that is not a param, is a field).

 "net.sf.jasperreports.engine.JasperReport" =>  Class of SubReport.

$P{<nameOfYourSubRptJasper>} => Expression of your subRpt passed like a param.

 2- I have declared in my JavaBean another attribute called "private Collection fieldSubDataSource(with naturally get and set methods).

3- in the main rpt i have added a field (called fieldSubDataSource with type java.util.Collection)  that I have set in my java app with a Collection object (that returned an array list containing the resulset that represents my subrpt data source) when i have filled all the other main rpt fields trough the resultset.

Resume:

In this way i've passed the subrpt like a param and the subrpt data source like a field of the main rpt and all works perfectly.

hope to help you bye.

 

Giovanni

...La puissance est rien sans controle...


 



Post Edited by giobby at 10/30/2009 11:43
Link to comment
Share on other sites

  • 3 years later...

I did it^^

Filling a report with hashmap "and bean" - though the bean has been added to the hashmap:

yes: [...].fillReport(report, hashMap, new JREmptyDataSource());

no: [...].fillReport(report, hashMap, beanDataSource);

 

I'll write down my experiences for me and if a tutorial is still wanted I could try to translate it (from German to English^^)...!?

Link to comment
Share on other sites

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