Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Use embedded image in beforeFactory()
rnyholm
Hi there!
I have a quick question, can I use a embedded image file in script beforeFactory()? If it's possible how can a achieve that?
Thanks!
Find more posts tagged with
Comments
mwilliams
Have you tried this:
reportContext.getDesignHandle().findImage("embeddedImageName");
rnyholm
<blockquote class='ipsBlockquote' data-author="'mwilliams'" data-cid="117452" data-time="1370648859" data-date="07 June 2013 - 04:47 PM"><p>
Have you tried this:<br />
<br />
reportContext.getDesignHandle().findImage("embeddedImageName");<br /></p></blockquote>
<br />
I tried this but it doesn't seem to work, which is very strange because I've debugged this and I get the embedded image but somehow it refuses to change the background image in the style to the embedded image.<br />
Any other suggestion?<br />
<br />
Btw I do it in this manner:<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>reportContext.getDesignHandle().findStyle("style").setBackgroundImage(reportContext.getDesignHandle().findImage("image.png"));</pre>
mwilliams
What's your BIRT version? Any way you can set up a simple example of what you've got so far, so I can see exactly what your setup is?
rnyholm
I have the Eclipse Business Intelligence and Reporting Tools SDK v3.7.2.<br />
I don't really know what examples you want, I've tried this in the beforeFactory() script:<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>reportContext.getDesignHandle().findStyle("style").setBackgroundImage(reportContext.getDesignHandle().findImage("image.png"));</pre>
And it should work but doesnt. But if I give the full path to the image it's working. But I cannot use this solution because after we deploy the application the path's will be wrong so I have to get the image from the embedded images.<br />
To do this even more confusing I've debugged it and this snippet <pre class='_prettyXprint _lang-auto _linenums:0'>reportContext.getDesignHandle().findImage("image.png")</pre> does find the image. This is tested by throwing an error whit the return value from methods, and if I refer to a image file that doesn't exists in the embedded files i get a null value but not when I refer to a correct image file that exists in the embedded files. So the problem is when I try to change background image in the beforeFactory() script to an embedded image, and seriously I soon start pulling my hair cause this is really strange.
rnyholm
I managed to get the image file in another way that working fine for now. But anyway the mystery remains why it couldn't change the background image from the embedded images.
Thanks for yor help!
mwilliams
Okay. Now that I fully see what you're trying to do, I've ran into this issue before and had the person log a bug.<br />
<br />
<a class='bbc_url' href='
https://bugs.eclipse.org/bugs/show_bug.cgi?id=386245'>https://bugs.eclipse.org/bugs/show_bug.cgi?id=386245</a><br
/>
<br />
It seems that the embedded image option even though it appears to be available doesn't actually work. There is a proposed patch in the bug report. I'm not sure what you're doing now, but if you place your image in your resources folder, you should be able to call the image with something like:<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
reportContext.getDesignHandle().findMasterPage("myMasterPage").setStringProperty("backgroundImage","bgImage.jpg");
</pre>