2005 IR Help Posted September 2, 2006 Share Posted September 2, 2006 By: ferrald - ferrald JRBeanCollectionDataSource in a subreport 2005-07-25 06:04 Hello together I try to use an JRBeanCollectionDataSource in my subreport. In my masterreport the following works well: Part of ViewPdfKTitelAction.java: *************************************************************** JRBeanCollectionDataSource ds = new JRBeanCollectionDataSource(data); // Datasource bereitstellen byte[] pdfData = JasperRunManager.runReportToPdf(jrFilename, parameters, ds); *************************************************************** I have designed my reports with IReport. For tests, my report and my subreport works with a query in the "reportquery/report sql query". The compiled report works also, when i send a db connection to the report, and i haven't to recompile the report. In this case, the subreport take the connection from the report and shows my his data. In the SQL from my Subreport, i can use the Parameter $P{a_fieldname} to select only the related datas. where/how can i send an JRBeanCollectionDataSource to the Subreport? how can my subreport decide witch data he have to show? and witch settings have i to make in the masterreport? I already take a look on this: http://geocities.yahoo.com.br/robertofurutani/java/Tutorial_JasperReports/ but it's spanish, and i don't understand... Happy for every help and a sample... Thanks Pascal By: ferrald - ferrald RE: JRBeanCollectionDataSource in a subreport 2005-07-29 03:06 Hi there one problem i have solved. I can send an JRBeanCollectionDataSource to the Subreport But i have still no idea how my subreport can decide witch data he have to show. My probleme is still here: How can i make the same with the JRBeanCollectionDataSource what i made with SQL in my subreport when i write something like: select * from table where field = $P{Name_Of_Paramerter}; i have done the follow to send the JRBeanCollectionDataSource to my subreport: In Java: ********************************************************** //Parameter settings Map parameters = new HashMap(); parameters.put("ReportTitle", "Jasper Report"); parameters.put("baseDir", (new File(jrFilename)).getParentFile()); // here i send the datasource for the subreport as parameter to the masterreport parameters.put("datasource",new JRBeanCollectionDataSource(sdata)); // show the report in the browser JRBeanCollectionDataSource ds = new JRBeanCollectionDataSource(data); byte[] pdfData = JasperRunManager.runReportToPdf(jrFilename, parameters, ds); response.setContentType("application/pdf"); response.setContentLength(pdfData.length); ServletOutputStream ouputStream = response.getOutputStream(); ouputStream.write(pdfData); ouputStream.flush(); ouputStream.close(); ********************************************************** In my masterreport: ********************************************************** i have define a parameter datasource as java.lang.object properties of the element "subreport": under subreport i mad the settings: use datasource expression $P{datasource} under subreport (other) subreport expression: "subreport_name" parameter: TIL expression: $F{TIL} ********************************************************** in my subreport ********************************************************** i have define a parameter TIL as java.lang.double (this isn't working, i don't know why...) ********************************************************** Hope, i have listed here all changes i made in the reports and other persons can profit from this part solution, and someone can help me with my problem... greetings pascal 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