how to pass a parameter to subreport

Hello all, am having problems deploying jasper reports in a web application. the problem is that the reports work fine when they are on my computer but as soon as their on a web app they stop working. My report has a subreport and that is were the problem lies. The "SUBREPORT_DIR" in the main report .jrxml is hard coded to my computer and will not work if I try it on another compuer or in a web app. I have found that other people have the same problem but I have not come across a solution that works for me. I would grately appreciate some assistance.  I would like to be able to pass the "SUBREPORT_DIR" value from a java program but don't know how to do so. Thank you for your help

gilbert_1's picture
Joined: May 28 2013 - 1:22am
Last seen: 9 years 6 months ago

1 Answer:

Have a look at the jasperreports source package. There are a bunch of examples, especially an example with two different ways to execute subreports:

http://jasperreports.sourceforge.net/sample.reference/subreport/

For general, you either have to pass a ready compiled subreport (object) e.g. in a parameter to your masterreport, or you will have to pass a valid subreport expression. This could for example be $P{SUBREPORT_DIR} + "mysubreport.jasper", where $P{SUBREPORT_DIR} has to be a valid path, accessible from your webapplication.

Cheers, Thomas

http://www.thomaszimmer.net

 

Thomas Zimmer's picture
Joined: Oct 2 2012 - 1:35am
Last seen: 7 hours 31 min ago
Feedback
randomness