tush Posted May 28, 2008 Share Posted May 28, 2008 Hi All,I want to create a report using few subreports. The data source I want to use is java beans. But the problem here is iReport allows only one java bean as a data source. I have MainRptBean java bean for main report and SubRptBean java bean for subreport. This means different beans for each report. I tried running both report separately, these are working fine but as soon as this subreport is added to main report I can not see the contents of the subreport when I run main report. I want to know how to set up different java bean data source for subreport. The example code is as follows. This below example is using just one subreport but actually I want to use lots of subreports in my actual program. This is the java bean data source for main report. Main report is fetching the data from this bean.Code:import java.util.ArrayList;import java.util.List;public class MainRptBean { private String name; private String age; /** * @return Returns the age. */ public String getAge() { return age; } /** * @param age The age to set. */ public void setAge(String age) { this.age = age; } /** * @return Returns the name. */ public String getName() { return name; } /** * @param name The name to set. */ public void setName(String name) { this.name = name; } public static List generateCollection() { MainRptBean mRtp = new MainRptBean(); mRtp.setAge("25"«»); mRtp.setName("John"«»); List list = new ArrayList(); list.add(mRtp); return list; }} This is the java bean data source for subreport. I want subreport to use the data from this java bean.Code:[code]import java.util.ArrayList;import java.util.List;public class SubRptBean { private String subject; private String marks; /** * @return Returns the marks. */ public String getMarks() { return marks; } /** * @param marks The marks to set. */ public void setMarks(String marks) { this.marks = marks; } /** * @return Returns the subject. */ public String getSubject() { return subject; } /** * @param subject The subject to set. */ public void setSubject(String subject) { this.subject = subject; } public static List generateCollection() { SubRptBean sRtp = new SubRptBean(); sRtp.setMarks("99"«»); sRtp.setSubject("English"«»); List list = new ArrayList(); list.add(sRtp); return list; }} Please let me know if the proble m is not clear to anybody. Thanks in advance. Tush Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now