Jump to content
We've recently updated our Privacy Statement, available here ×

SUPREPORT - ITS BLANK


cparis

Recommended Posts

My problem is this: I have to do a report with info A and info B, for this I made a master report and subreport with IReports 1.2.6, the master report contain the info A and subreport, the subreport contain info B.In subreport properties I have this information:[li]SUBREPORTConnection / Datasource expression: Use datasource expression $P{REPORT_DATA_SOURCE}[/li][li]SUBREPORT (Other)Subreport expression class: net.sf.jasperreports.engine.JasperReportSubreport expression: $P{SUBREPORT}[/li]Im using a web application to export the report in two formats html and pdf; but when I try to export it the information is not displayed, the report is blank I got this in my class:Statement statement = DataBaseService.getInstance().getConnection().createStatement(); ResultSet rs = statement.executeQuery(super.queryCriteria(query));ResultSet subrs = statement.executeQuery(super.queryCriteria(subquery));JRDataSource ds = new JRResultSetDataSource (rs); JRDataSource subds = new JRResultSetDataSource (subrs);URL urlJasper = this.getClass().getResource("../../../jasper/cs16.jasper");URL urlSubreport = this.getClass().getResource("../../../jasper/cs16TE.jasper");JasperReport Report = (JasperReport) JRLoader.loadObject(urlJasper);JasperReport Subreport = (JasperReport) JRLoader.loadObject(urlSubreport);Map params = new HashMap(); params.put(JRParameter.REPORT_LOCALE,getLocale(request)); params.put(JRParameter.REPORT_DATA_SOURCE, subds);params.put("SUBREPORT", Subreport);JasperPrint reportPrint = JasperFillManager.fillReport(Report, params, ds); request.getSession().setAttribute(BaseHttpServlet.DEFAULT_JASPER_PRINT_SESSION_ATTRIBUTE,reportPrint);Anybody help me with this?Thanks,

 

Post edited by: cparis, at: 2006/11/17 11:37

Link to comment
Share on other sites

  • Replies 5
  • Created
  • Last Reply

Top Posters In This Topic

Can you elaborate a bit on your design? I am not quite sure what you mean by info A and info B. Is info B a field/subset of data from info A? Typicially you cannot pass $P{REPORT_DATA_SOURCE} to a subreport effectively.

 

If you outline a bit more about the data structure I will try to suggest something productive :).

 

 

Edit: I read the code that you posted again, it looks like you are passing a unique datasource to the report in the parameters map which is intended to be the datasource for the subreport. In that case, pass it as a unique parameter name (e.g. "SUB_DATASOURCE") and then pass the parameter to the sub-report in the datasource expression.

 

As well, you shouldn't pass REPORT_DATA_SOURCE to the report as that parameter is automaticially created when you fill the report with the datasource passed to that method.

 

HTH,

Robin

 

Post edited by: rsilver@bfm.bm, at: 2006/11/20 16:06

Post edited by: rsilver@bfm.bm, at: 2006/11/20 16:07

Link to comment
Share on other sites

Hi,

 

Why do you pass to the subreport the REPORT_DATA_SOURCE built-in parameter???

This means you are passing to the subreport the same data source the master report had. Besides the fact that the subreport gets the wrong data source (the A datasource) by the time it reaches the subreport it will also be already consumed by the master report, so no wonder the subreports does not find any more records to iterate though (the record pointer reached the end of the A data source).

 

Why do you pass the subreport data source using the REPORT_DATA_SOURCE parameter? Can't you invent a parameter of your own? Leave the REPORT_DATA_SOURCE parameter alone! You don't need it. Define your own parameter in the master and pass it as the data source for your subreport.

 

I hope this helps.

Teodor

Link to comment
Share on other sites

  • 6 years 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...