Jump to content

subreport has disappeared


kaunietiss

Recommended Posts

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

  • Replies 10
  • Created
  • Last Reply

Top Posters In This Topic

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

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,

Lucian

Post edited by: lucianc, at: 2006/08/30 14:32

Link to comment
Share on other sites

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

  • 1 month later...

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...