bobz28 Posted August 20, 2010 Share Posted August 20, 2010 Hi All,I am trying to create a template for a report that can be from 1 to many (around 10 reports) in one report output. Depending on the user input (~10 drop down lists and each list if selected will eventually populate a report). Ex. if user select inputs from 5 drop down lists then I will have to generate 5 reports, one after another, if they select 10 then create 10... What is a best way to accomplishing this?Thanks-Bob Link to comment Share on other sites More sharing options...
shrije Posted August 23, 2010 Share Posted August 23, 2010 Please find the below code. One report corresponds to the one jasper file. Appending one report with another can happen with the code given below. It will be an as-is append.Code: for( int i = 0; i < listOfInputjasperpath.size(); i++ ) { try { JasperPrint jasperPrint = JasperFillManager.fillReport( listOfInputjasperpath.get( i ) + ".jasper", params ); listOfJasperPrint.add( jasperPrint ); } catch( JRException e ) { throw new RuntimeException( "Exception related to Jasper Filling Data " + e ); } Link to comment Share on other sites More sharing options...
bobz28 Posted August 23, 2010 Author Share Posted August 23, 2010 Hi shrije, Thanks for your reply, I am using Jasper with Spring framework and the Jasper template is the same for all reports... Can code similar to this happen inside the template or a scriptless? Bob Link to comment Share on other sites More sharing options...
shrije Posted August 24, 2010 Share Posted August 24, 2010 It will stll with the same template since jasperPrint is the one which will be different for different reports in your case. Just that you have to provide different datasources to the same jasper file to get the jasper print object to finally append them. Link to comment Share on other sites More sharing options...
Teodor Danciu Posted August 24, 2010 Share Posted August 24, 2010 Hi, Such code needs to stay in your Spring application. I cannot be part of a report template or scriptlet.It is your own application code. I hope this helps.Teodor Link to comment Share on other sites More sharing options...
bobz28 Posted August 24, 2010 Author Share Posted August 24, 2010 Hi, I am using Spring+Hibernate, how can I appending one report after another in Spring+Hibernate framework? Thanks,Bob Link to comment Share on other sites More sharing options...
bobz28 Posted August 25, 2010 Author Share Posted August 25, 2010 Hi,Can somebody help... How can I append one report after another in Spring Hibernate framework?Here is what is look like in the controller:Map<?,?> model = new HashMap<?,?>();List<?> report = getReport();String[] fields = new String[] {"a", "b", "c"};HibernateDataSource ds = new HibernateDataSource(report, fileds);model.put("title", title);model.put("dataSource", ds);...return model;Thanks a lot.Post Edited by bobz28 at 08/25/2010 14:43 Link to comment Share on other sites More sharing options...
bobz28 Posted August 26, 2010 Author Share Posted August 26, 2010 Hi All,Well, I think I can create a subreport to handle this issue, but is there a way to call and pass it diff datasources? Thanks- 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