why the subreport did not display?

0

I created a subreport with no parameters. I found the subreport didn't display as expected. If run the subreport itself, it does display.

Here's the iReport screenshot.

 

The following picture is the FileSafe Backup Report I'm currently using. I'm trying to migrate to JasperReports.

 

Thanks advance for any help.



Post Edited by ageofjava at 05/10/2010 09:36



Post Edited by ageofjava at 05/10/2010 09:43
ageofjava's picture
Joined: Apr 8 2010 - 8:25pm
Last seen: 1 year 3 months ago

6 Answers:

1
In order to sub report display you need to pass some data (data source) to it.
Can you please describe in details your sub report configuration?

Best regards,
Taras Matyashovsky
tmatyashovsky's picture
Joined: May 30 2009 - 2:53am
Last seen: 9 years 10 months ago
1

Taras, thanks very much for your kind help.

The subreport uses the same connection as the master report, the local FileSafe-Backup-20100330-162507-001-129144110565671150.xml file. I created the subreport and the master report separately and then add the subreport to the master by dragging the "Subreport" icon from the palette. I didn't sepcify any parameters for the subreport.

I thought the subreport already had its own data source. Should I pass a data source to it from the master report?

You can run the report after simply downloading the 3 attachments to a same folder.  filesafebackup.jrxml is the master report, clientsnotbackedup.jrxml is the subreport and FileSafe-Backup-20100330-162507-001-129144110565671150.xml is the data source used by both the reports.

Best regards,

Ling



Post Edited by ageofjava at 05/11/2010 03:06
ageofjava's picture
Joined: Apr 8 2010 - 8:25pm
Last seen: 1 year 3 months ago
0
Hi Ling,

When you create sub report the wizard should appear.
In mentioned wizard on the step2 please select appropriate connection (from the master report or create a separate one).
On the step 3 do not forget to pass some parameters from master report to the sub report if needed.

Hope that will help.

P.S. Cannot find attachment. Please upload it once more if it won't help.
tmatyashovsky's picture
Joined: May 30 2009 - 2:53am
Last seen: 9 years 10 months ago
0
The sub report still doesn't display, although it gets display if running it as a master report.

The attachments are located at the bottom of the thread #74189. Please search the string "Attachments:" in this page. You'll see the 3 attachments right below the highlighted "Attachments:".

Thanks again for your kind help.
ageofjava's picture
Joined: Apr 8 2010 - 8:25pm
Last seen: 1 year 3 months ago
4

I investigated the problem you have.

First of all, correct the name of sub report to clientsnotbackedup.jasper. But that's the minor issue.

Also don't forget to pass parameters from master report to sub report. This is done in parameters property of sub report element. Select it and press copy from master and

choose needed parameters. One is for sure needed - SUBREPORT_DIR.

The main issue: you have not set the data source for the sub report.

To do that:

  • select your subreport element.
  • change connection type to "use a data source expression"
  • change data source expression to
    • ((net.sf.jasperreports.engine.data.JRXmlDataSource)$P{REPORT_DATA_SOURCE}).subDataSource("/report/client[@status='never']")
  • the path "/report/client[@status='never']" was taken from yours subreport query, correct it if needed
  • run the master report
  • that worked for me. If it will work for you - add some karma points :)
  •  

Best,

Taras Matyashovsky

 

tmatyashovsky's picture
Joined: May 30 2009 - 2:53am
Last seen: 9 years 10 months ago
0
Taras,

The solution works for me. Thanks a lot for your continuous help. Because the sub report used the same local xml file as the master one, I selected the option "use the same connection as the master report". It was wrong.

For sure, you got your karma points

Sincerely,

Ling
ageofjava's picture
Joined: Apr 8 2010 - 8:25pm
Last seen: 1 year 3 months ago
Feedback