kaunietiss Posted August 25, 2006 Share Posted August 25, 2006 Hi, i have a report of 1 page and it's ok but when i add some more data to the report it already contains of 2 pages. It would be ok but few lines of the report disapears (look at the attached image). Btw those lines (which has disappeared) are in the subreport. Any suggestions how to get back my lines? Post edited by: kaunietiss, at: 2006/08/25 06:45 Link to comment Share on other sites More sharing options...
kaunietiss Posted August 25, 2006 Author Share Posted August 25, 2006 size=356]http://www.jasperforge.org/components/com_joomlaboard/uploaded/images/VATS.jpg Post edited by: kaunietiss, at: 2006/08/25 06:45 Link to comment Share on other sites More sharing options...
lucianc Posted August 25, 2006 Share Posted August 25, 2006 Where (on which band) is your subreport placed? What data source/connection expression are you using for the subreport? Link to comment Share on other sites More sharing options...
kaunietiss Posted August 25, 2006 Author Share Posted August 25, 2006 i have report with 2 subreports in the detail band. one of those subreports contains some fields and a subreport (all in the detail band) which sometimes disappears.Connection/Datasource Expression is set to "use datasource expression" and im sending parameter value from my application. Link to comment Share on other sites More sharing options...
lucianc Posted August 29, 2006 Share Posted August 29, 2006 Not sure what could cause this. Could you post a (simplified) sample, or relevant JRXML fragments so that we would be able to replicate the behaviour? Regards,LucianPost edited by: lucianc, at: 2006/08/29 08:15 Link to comment Share on other sites More sharing options...
kaunietiss Posted August 30, 2006 Author Share Posted August 30, 2006 [file name=report.zip size=13881]http://www.jasperforge.org/components/com_joomlaboard/uploaded/files/report.zip[/file] SFVATSList.jrxml is the subreport which sometimes disappears. Link to comment Share on other sites More sharing options...
lucianc Posted August 30, 2006 Share Posted August 30, 2006 The cause of the behaviour is probably the fact that you are reusing the same data source to fill a report multiple times. A data source is similar to a java.util.Iterator, it exhausts its data when used. To reuse it, you have to either rewind it (if it's a JRRewindableDataSource), or recreate it. Read this discussion, it's about the same thing:http://www.jasperforge.org/index.php?option=com_joomlaboard&Itemid=&func=view&catid=8&id=421 HTH,LucianPost edited by: lucianc, at: 2006/08/30 14:32 Link to comment Share on other sites More sharing options...
kaunietiss Posted September 7, 2006 Author Share Posted September 7, 2006 lucianc wrote:When you pass a data source to a subreport, the entire data source gets exhausted (i.e. all the rows are consumed), not only the first row in the data source. Your data source is the map vector, therefore the subreport would consume the entire vector, not just the first map.You need to pass a fresh data source each time the subreport gets instantiated. For example, if $P{SubreportData} is a collection of maps, you can create a new data source based on it for each subreport instantiation:<dataSourceExpression>new JRMapCollectionDataSource($P{SubreportData})</dataSourceExpression>The alternative I mentioned was to rewind the data source for the subreport in the scriptlet (that is, if your data source is rewindable). For example, if you provide the data source for the subreport using a parameter named "SubreportDataSource", you can do the following in the report scriptlet's beforePageInit() method:((JRRewindableDataSource) getParameterValue("SubreportDataSource")).moveFirst();HTH,Lucian and my $P{SubreportData} is a type of JRDataSource and if i write new JRMapCollectionDataSource($P{SubreportData}) i got the error: Code: [jrc] Compiling 1 report design files. [jrc] File : E:JAVAPROJECTSjMonarchreportsSFPage.jrxml ... FAILED. [jrc] Error compiling report design : E:JAVAPROJECTSjMonarchreportsSFPage.jrxml [jrc] net.sf.jasperreports.engine.JRException: Errors were encountered when compiling report expressions class file: [jrc] 1. The constructor JRMapCollectionDataSource(JRDataSource) is undefined [jrc] value = (net.sf.jasperreports.engine.JRDataSource)(new JRMapCollectionDataSource (((net.sf.jasperreports.engine.JRDataSource)parameter_SFStatementListData.getValue()))); [jrc] <--------------------------------------------------------------------------------------------------------------------> [jrc] 2. The constructor JRMapCollectionDataSource(JRDataSource) is undefined [jrc] value = (net.sf.jasperreports.engine.JRDataSource)(new JRMapCollectionDataSource (((net.sf.jasperreports.engine.JRDataSource)parameter_SFStatementListData.getValue()))); [jrc] <--------------------------------------------------------------------------------------------------------------------> [jrc] 3. The constructor JRMapCollectionDataSource(JRDataSource) is undefined [jrc] value = (net.sf.jasperreports.engine.JRDataSource)(new JRMapCollectionDataSource (((net.sf.jasperreports.engine.JRDataSource)parameter_SFStatementListData.getValue()))); [jrc] <--------------------------------------------------------------------------------------------------------------------> [jrc] 3 errors [jrc] [jrc] at net.sf.jasperreports.engine.design.JRAbstractCompiler.compileReport(JRAbstractCompiler.java:193) [jrc] at net.sf.jasperreports.engine.design.JRDefaultCompiler.compileReport(JRDefaultCompiler.java:131) [jrc] at net.sf.jasperreports.engine.JasperCompileManager.compileReportToFile(JasperCompileManager.java:127) [jrc] at net.sf.jasperreports.engine.JasperCompileManager.compileReportToFile(JasperCompileManager.java:109) [jrc] at net.sf.jasperreports.ant.JRAntCompileTask.compile(JRAntCompileTask.java:398) [jrc] at net.sf.jasperreports.ant.JRAntCompileTask.execute(JRAntCompileTask.java:252) [jrc] at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275) [jrc] at org.apache.tools.ant.Task.perform(Task.java:364) [jrc] at org.apache.tools.ant.Target.execute(Target.java:341) [jrc] at org.apache.tools.ant.Target.performTasks(Target.java:369) [jrc] at org.apache.tools.ant.Project.executeTarget(Project.java:1214) [jrc] at org.apache.tools.ant.Project.executeTargets(Project.java:1062) [jrc] at org.apache.tools.ant.Main.runBuild(Main.java:673) [jrc] at org.apache.tools.ant.Main.startAnt(Main.java:188) [jrc] at org.apache.tools.ant.launch.Launcher.run(Launcher.java:196) [jrc] at org.apache.tools.ant.launch.Launcher.main(Launcher.java:55)BUILD FAILED Link to comment Share on other sites More sharing options...
lucianc Posted September 7, 2006 Share Posted September 7, 2006 What I suggested was "if $P{SubreportData} is a collection of maps", i.e. $P{SubreportData} would be a java.util.Collection instance containing java.util.Map objects. Regards,Lucian Link to comment Share on other sites More sharing options...
kaunietiss Posted September 8, 2006 Author Share Posted September 8, 2006 finally, i've solved my problem with scriptlet. lucianc, thank you very much for all your help:) Link to comment Share on other sites More sharing options...
krishnamurthi Posted November 7, 2006 Share Posted November 7, 2006 Dear Kaunietiss, Im facing the same problem what u have mentioned.& i have followed the same method (scriptlet,JRMapCollectionDataSource) but i got the error . Can u suggest me, how to do this. Thanks a lot.(IF U GIVE ANY SAMPLE IT WILL BE VERY USEFUL FOR ME) :blink: :) :) 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