Jaspersoft Studio - Reports Directory

If I have a report with a subreport, I can get the reports-directory easely wiht the parameter @P{SUBREPORT_DIR}.
If the report has no subreport, this parameter is missing.
How can I determine the path to the reports directory without having a subreport?
Reason for this: I need the path to reference a graphic file.

Thanks for any hint.
Fritz

Hi Fritz,
you mean the directory where the report filtes are stored, right?
Is that directory totally arbitrary and does not depend on the location of the AppServer-directory?
The reason why I ask: I can not imagine a situation where a report directory is completely independent of the AppServer-directory, and the app does not know at all where it resides.
Because then the app could not invoke the report, I guess.

Hi Fritz,

you could just pass the path of the image to the report using a hash-map when calling the report from Servoy.
Then from within the report you can use this from a variable and link to the path.

Hope this helps.

Hi Marc & Bernd

Thanks for your comments.
The situation is this:

  • I have a report directory in my dev. environment and one in the production environment
  • the paths are obviously not the same
  • I store the custom graphic file alongside the report in the same direcotryy
    This said, I get the following behaviour:
  • Jaspersort Studio: just putting a “MyLogo.jpg” in the image Expression property of the Image control works, the graphic Displays. Doesn’t work either in dev. and prod.
  • puting a fully qualified path in front of the Image Name (e.g. “c:/myPath/MyLogo.jpg” works both in dev and prod but in that case, I have to change the path Information within the report before deploying. Not a very good idea.
  • in a report with subreports I can use $P{SUBREPORT_DIR} + “/MyLog.jpg” and it works both in dev and prod
    The $P{SUBREPORT_DIR} Parameter will be created by Jasper only if I use a subreport. My Intention is now to use a function/Parameter/whatever to get the same Information as $P{SUBREPORT_DIR} and I will hve a truly portable Report.
    I hope, I did now express my intentions a little more precise :-)
    Thanks for any suggestions.

Hi Fritz,

yes, your goal was clear in your first post.
That’s why I suggested you pass the value using a hashmap.
Properties of the hashmap can be used as variables in the report.

Just in case somebody is interestet in the solution I found:

  • The path to the report Directory is stored in the servoy.properties file under the entry “directory.jasper.report”.
  • With the UserManager plugin it can be read and stored in the parameter object for JasperReport:
    taRepoParam.cReportDir = plugins.UserManager.getSettingsProperty(“directory.jasper.report”)
  • the image expression in the report looks then like: $P{cReportDir} + “/MyLogo.jpg”
    And it works :-)

murmi:
taRepoParam.cReportDir = plugins.UserManager.getSettingsProperty(“directory.jasper.report”)

  • the image expression in the report looks then like: $P{cReportDir} + “/MyLogo.jpg”

Like I suggested…
Great you’ve got that working!

Totally second you Marc, hashmaps are very powerful for use with Jasper
Allowing you to keep as much logic within Servoy as possible.