Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
THRUST SERVICES & TOOLS
CLOUD EDITIONS
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
possible to use image resource from classpath?
hedefalk
I need a logo in a couple of reports and I rather not embed it in the .rptdesign file. In the image dialog I have four options:
URI
Image file in shared resources
Embedded image
Dynamic image
I would like to get the image from classpath. I just tried Image file in shared resource, but I'm struggling how to use that correctly with a relative path that works in a deployed webapp. URI says something about web in the tooltip so that doesn't seem to be it either.
Do I need to do dynamic image and insert it runtime? I guess the problem with using a relative file location is that it probably wouldn't work design time, but that doesn't matter too much to me?
Thanks,
Viktor
Find more posts tagged with
Comments
JasonW
Take a look at this post. Specifically on using the image from a resource folder.
http://birtworld.blogspot.com/2010/09/birt-image-report-item.html
Jason
hedefalk
<blockquote class='ipsBlockquote' data-author="'JasonW'" data-cid="85064" data-time="1320782300" data-date="08 November 2011 - 12:58 PM"><p>
Take a look at this post. Specifically on using the image from a resource folder.<br />
<a class='bbc_url' href='
http://birtworld.blogspot.com/2010/09/birt-image-report-item.html'>http://birtworld.blogspot.com/2010/09/birt-image-report-item.html</a><br
/>
<br />
Jason<br /></p></blockquote>
<br />
<br />
Thanks, Jason!<br />
<br />
Unfortunately I couldn't figure it out by that resource alone. However, I found this thread:<br />
<br />
<a class='bbc_url' href='
http://www.eclipse.org/forums/index.php/m/362386/'>http://www.eclipse.org/forums/index.php/m/362386/</a><br
/>
<br />
and by that I figured I could set my resource folder to target/classes (which is standard output for both src/main/resource and classes in Maven. That will be the root of the classes in the webapp when running it in a container so then I could do:<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>engineConfig.setResourcePath(this.getClass.getResource("/").getPath())</pre>
<br />
and the relative path for design and runtime will be the same.<br />
<br />
Thanks,<br />
Viktor
JasonW
That should work fine, but I am curious why this did not work for you:
var jarfile = reportContext.getResource("birtimages.jar");myfulljarimage = "jar:"+jarfile.toString()+"!/green.png";myfulljarimage;
Jason
hedefalk
Well, i didn't try that one?
First off I don't have any jar for the images. These are images reused for both my webapp and the report. So they're in my classpath together with the classes in WEB-INF/classes inside my war.
Second I'm not that comfortable doing too much in js together with things like jars, so I rather just enter a path in the design view pointing to my images on classpath.
Thanks,
Viktor
JasonW
Sounds good.
Jason