views:

395

answers:

1

I am having one jasper report.Inside of the that main report I am adding one sub report.I am passing collections and parameters using java class(Not using sql query directly).It is compiling successfully.

But while running it shows only main report.It is not showing the sub report.And also it is not making any error. It is just giving some empty space for that place. Can any one tell me how to solve this? What are all the rules I have to follow while adding subreport in jasper?

A: 

Supposing you are passing the data to the report as a Java Beans Collection, then i will assume you have one field as a java.util.List which will be used to feed the subreport.

Your original bean will be something like:

public class ParentBean{
     int id;
     String fatherName;
     List<ChildBean> childrenList;

     //setters and getters goes here
}

When calling the Main Report, you should add three fields, the last of them is of type List.

Select the subreport, open the Properties Dialog, in Connection/Data Source Expression, choose Use Data source expression put the following:

new JRBeanCollectionDataSource($F{childrenList})

In your subreport, use the fields in the ChildBean.

NOTE: Dialogs names are from an old iReport version, might changed now.

medopal