Jaspersoft Studio - Reports Directory

Questions and answers on developing, deploying and using plugins and JavaBeans

Jaspersoft Studio - Reports Directory

Postby murmi » Fri Sep 30, 2016 5:29 pm

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
Fritz Maurhofer
Maurhofer Informatik AG
CH-8340 Hinwil
murmi
 
Posts: 16
Joined: Thu Jul 22, 2010 5:10 pm

Re: Jaspersoft Studio - Reports Directory

Postby Bernd.N » Fri Sep 30, 2016 5:51 pm

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.
Bernd Korthaus
LinkedIn
Servoy 7.4.9 SC postgreSQL 9.4.11 Windows 10 Pro
User avatar
Bernd.N
 
Posts: 474
Joined: Mon Oct 21, 2013 5:57 pm
Location: Langenhorn, North Friesland, Germany

Re: Jaspersoft Studio - Reports Directory

Postby mboegem » Fri Sep 30, 2016 6:15 pm

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.
_____________________
Marc Boegem
Solutiative / JBS Group, Partner
• Servoy Certified Developer
• Servoy Valued Professional
• Freelance SAN Developer

Image
User avatar
mboegem
 
Posts: 1382
Joined: Sun Oct 14, 2007 1:34 pm
Location: Hoofddorp, The Netherlands

Re: Jaspersoft Studio - Reports Directory

Postby murmi » Mon Oct 03, 2016 9:27 am

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.
Fritz Maurhofer
Maurhofer Informatik AG
CH-8340 Hinwil
murmi
 
Posts: 16
Joined: Thu Jul 22, 2010 5:10 pm

Re: Jaspersoft Studio - Reports Directory

Postby mboegem » Mon Oct 03, 2016 10:13 am

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.
_____________________
Marc Boegem
Solutiative / JBS Group, Partner
• Servoy Certified Developer
• Servoy Valued Professional
• Freelance SAN Developer

Image
User avatar
mboegem
 
Posts: 1382
Joined: Sun Oct 14, 2007 1:34 pm
Location: Hoofddorp, The Netherlands

Re: Jaspersoft Studio - Reports Directory

Postby murmi » Tue Oct 04, 2016 9:36 am

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 :-)
Fritz Maurhofer
Maurhofer Informatik AG
CH-8340 Hinwil
murmi
 
Posts: 16
Joined: Thu Jul 22, 2010 5:10 pm

Re: Jaspersoft Studio - Reports Directory

Postby mboegem » Tue Oct 04, 2016 11:53 am

murmi wrote: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!
_____________________
Marc Boegem
Solutiative / JBS Group, Partner
• Servoy Certified Developer
• Servoy Valued Professional
• Freelance SAN Developer

Image
User avatar
mboegem
 
Posts: 1382
Joined: Sun Oct 14, 2007 1:34 pm
Location: Hoofddorp, The Netherlands

Re: Jaspersoft Studio - Reports Directory

Postby Mccourt.cordingley1372837951 » Wed Oct 05, 2016 12:25 pm

Totally second you Marc, hashmaps are very powerful for use with Jasper
Allowing you to keep as much logic within Servoy as possible.
User avatar
Mccourt.cordingley1372837951
 
Posts: 28
Joined: Wed Jul 03, 2013 9:52 am


Return to Plugins and Beans

Who is online

Users browsing this forum: No registered users and 1 guest