emi Posted September 24, 2007 Share Posted September 24, 2007 hello I have simple master report with subreports. How can I put the parameters into subreports ?When I put this in main report everything is ok, but in subreports it's value null Map<String, Object> params = new Hashtable<String, Object>(); JasperReport jasperReport = JasperCompileManager.compileReport( classLoader.getResource( mainReport.getFile() ).getFile() ); for ( Report report : mainReport.getSubReports() ) { JasperReport reportCompiled = JasperCompileManager.compileReport( classLoader.getResource( report.getFile() ).getFile() ); params.put( report.getName(), reportCompiled ); if ( report.hasSubreports() ) { for ( Report subReport : report.getSubReports() ) { JasperReport subReportCompiled = JasperCompileManager .compileReport( classLoader.getResource( subReport.getFile() ).getFile() ); params.put( subReport.getName(), subReportCompiled ); params.put( "text", new String( text ) ); } } } return JasperFillManager.fillReport( jasperReport, params ,new JREmptyDataSource() ); [file name=declaration_mainData.jrxml size=28976]http://www.jasperforge.org/components/com_joomlaboard/uploaded/files/declaration_mainData.jrxml[/file] Link to comment Share on other sites More sharing options...
arianhojat Posted September 25, 2007 Share Posted September 25, 2007 Im a newbie but maybe didnt reference the parameter of the subreport in the main jrxml file? <parameter name="ProductsSubreport" class="net.sf.jasperreports.engine.JasperReport"></parameter> btw, im curious. where did you get function hasSubreports()? Thats nifty, simple xml parsing or part of API i didnt see in javadoc? 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