Jump to content
Changes to the Jaspersoft community edition download ×

Problems with collections in our reports


Recommended Posts

By: Juarez Alvares Barbosa Junior - juarezjunior

Problems with collections in our reports

2003-12-03 09:58

Hi, I am just copying my question and the advice provided by Mr. Teodor Danciu, in case other people have the same doubt.

 

Dear Mr. Teodor Danciu,

 

We are considering the adoption of JasperReports as the report engine to our J2EE projects and currently I am conducting some tests using it.

 

I am having difficulties trying to generate a report using the dori.jasper.engine.data.JRBeanCollectionDataSource data source.

 

The problem is that our beans (VOs) have collections of other beans (VOs) and I did not find any information of what to do in such a situation.

 

I've found the reply below from you where you explain that when we have a parent bean and a child one we just need to declare the field as

java.lang.Object, perform the cast to the appropriate type and invoke the

methods in a expression.

 

http://sourceforge.net/forum/message.php?msg_id=1821764

 

That's ok !!! I also have this same structure (MemberVO has a JugVO) but what about collections ?

 

Attached is the code of our VOs (the ones in the list passed in to the constructor of JRBeanCollectionDataSource). Please note that this value object has a Set of courses (which are CourseVOs)...

 

May you advise something regarding this issue ?

 

I am looking forward to your reply !

 

Thanks a lot !

 

 

public class MemberVO implements Serializable {

 

private Set courses;

 

private JugVO jug;

 

//getters and setters for each field

 

 

Hi,

 

If you want to list information from a child collection, then you need to

use subreports.

The main report will iterate through the main collection of objects and for

each of them

you'll probably have a subreport that will iterate through the collection of

children.

 

Check the "subreport" sample provided. You'll supply to your subreport a

JRBeanCollectionDataSource

that will wrap the children collection just as you do for the main report.

You'll use the

<dataSourceExpression> tag.

 

I hope this helps.

Teodor

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