prinsesajade Posted April 16, 2009 Share Posted April 16, 2009 hi! can anyone help me with this or any idea?i have a main report with 3 subreports (Product, Agency1, Agency2)..this is how it works..my first subreport (Product) have these fields Agency1Count and Agency2Count..the values of these fields will be dependent on the number of records processed in my other subreports(Agency1 and Agency2)..so if Agency1 has 12 records and 10 for Agency2 my Product subreport should display 12 for Agency1Count and 10 for Agency2Count..and here comes my problem..i don't know how i can pass these values from one subreport to another..do u have any idea?please let me know...thanks in advance.. Link to comment Share on other sites More sharing options...
prinsesajade Posted April 16, 2009 Author Share Posted April 16, 2009 i have just found the answer to my problem..i only have to add the same parameter (including the name) in my main report..say i have this parameter RATE in my subreport which is a map i just have to add the same paramter in my main report and in Subreport-->Properties-->Subreport Parameters.. Link to comment Share on other sites More sharing options...
miret Posted April 17, 2009 Share Posted April 17, 2009 Did the method you described above actually work?For some reason, I am also unable to pass subreport parameters... these are actually "Fields" in the subreport... does that make a difference?But my problem could also be that the subreports are somehow "hidden" and just appear blank... does anybody know how I could solve this issue?Thank you all in advance for your hints! Link to comment Share on other sites More sharing options...
prinsesajade Posted April 17, 2009 Author Share Posted April 17, 2009 yes it worked for me..ur problem is the fields of ur subreport r blank?this is how i make a subreport..i put the datasource and path of my subreport in a map..(see code below) then in ur master report create a parameter with name the same as the key u used for putting the path/datasource in the map..ex. SUBREPORT_DIR -- classType = java.lang.String SUBREPORTDATASOURCE -- net.sf.jasperreports.engine.JRDataSourcethen in subreport properties in subreport expression put the variable u used for the path of ur subreport and in the connection expression put the variable u used for the datasource..this is the best way i can explain this..hope this helps.. Code:Map<String, Object> params = new HashMap<String, Object>();params.put("SUBREPORT_DIR", urreportpathhere);params.put("SUBREPORTDATASOURCE", urdatasourcehere);JasperPrint print =JasperUtil.fillReport(mainreportpath, params, mainreportdatasource); Link to comment Share on other sites More sharing options...
miret Posted April 17, 2009 Share Posted April 17, 2009 Thank you for your quick reply!Both my mainReport datasource and my subReport datasource are created through a common list of dataBeans... perhaps that's my mistake?Do the two dataSources need to be separate?I'll give it a try...Thanks again! Link to comment Share on other sites More sharing options...
prinsesajade Posted April 17, 2009 Author Share Posted April 17, 2009 so the datasource of ur main and subreport are the same?still try to put ur datasource in the map..just try!hope this will help.. Link to comment Share on other sites More sharing options...
miret Posted April 17, 2009 Share Posted April 17, 2009 Thank you so much! It worked! :-) Link to comment Share on other sites More sharing options...
prinsesajade Posted April 21, 2009 Author Share Posted April 21, 2009 really?wow...hehe congrats! Link to comment Share on other sites More sharing options...
harinderrakkar Posted May 11, 2009 Share Posted May 11, 2009 Go to SubReport Properties>Subreport Properties(others)>then in subreport parameter just click "Copy from master" Button to pass parameter from one Master report to other.Hope it will work for you. Regards Harinder Singh Link to comment Share on other sites More sharing options...
itpragmatic Posted October 4, 2010 Share Posted October 4, 2010 hello..this is pretty older post but i am hopeful to get some clue from here. I am having same scenario. one main report and 2 subreports (DataDetails and ProcessDetails.) Main report and DataDetails use jdbc connection while ProcessDetails must use JRDataSource. I am having problem while executing this within java file. I tried in following way.1. created a java bean for the ProcessDetails(sub report which uses JRDataSource) and in the class file called its instance.2. Main report file and DataDetails(both uses database connection) already exist. Didn't change anything in that.3. In ProcessDetails subreport, connection type is kept to "Use a DataSource expression" and Data Source Expression is set to $F{newBeanField}(This is defined in java bean file).4. in main class I did following, please see the code.5. Now my problem is as main report and DataDetials(subreport1) are connection oriented and ProcessDetails uses JRDataSource, I am not able to fill the report using either JasperPrint print = JasperFillManager.fillReport(fileName, jasperParameter, jbs); or JasperPrint print = JasperFillManager.fillReport(fileName, jasperParameter, conn);6. Am i committing mistake anywhere? I know we can't use both connection and jrdatasource in fillreport. What I should change in order to generate every report. Please suggest/help/advise. Thank you in advance.Code:ArrayList<JasperBeanSample> list = new ArrayList<JasperBeanSample>(); JasperBeanSample jasperBeanSample1 = new JasperBeanSample(); jasperBeanSample1.setId(10); jasperBeanSample1.setName("abcabc"); jasperBeanSample1.setEmailId("abc@gmail.com"); list.add(jasperBeanSample1); JasperBeanSample jasperBeanSample2 = new JasperBeanSample(); jasperBeanSample2.setId(20); jasperBeanSample2.setName("xyzxyz"); jasperBeanSample2.setEmailId("xyz@yahoo.com"); list.add(jasperBeanSample2); JasperBeanSample jasperBeanSample3 = new JasperBeanSample(); jasperBeanSample3.setId(30); jasperBeanSample3.setName("pqrpqr"); jasperBeanSample3.setEmailId("pqr@hotmail.com"); list.add(jasperBeanSample3); JRBeanCollectionDataSource jbs = new JRBeanCollectionDataSource(list); //jasperBeanSample1.setNewBeanField(jbs); Map<String, Object> jasperParameter = new HashMap<String,Object>(); jasperParameter.put("newBeanParameter", list); JasperPrint print = JasperFillManager.fillReport(fileName, jasperParameter, jbs); //JasperPrint print = JasperFillManager.fillReport(fileName, jasperParameter, conn); Link to comment Share on other sites More sharing options...
kcronin Posted November 2, 2010 Share Posted November 2, 2010 I gave you a plus since that was the exact answer I needed and was awesome (even though you solved it yourself, you still solved it) 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