Home
Analytics
Dynamic Image in BIRT
javi82
I want to add an image to my report that should depend on a condition. If the condition is true, an image must appear and if there is false the image would be different.
I follow the following steps (extracted of the document birtCrossTabTutorialAdvanced.pdf):
1.- I drag an image item from the palette to the layout.
2.- I select image from an URI and use the following expression in the field enter URI:
If (true) "image_1.gif" else "image_2.gif"
3.- On click OK, the following message appears:
The image cannot be loaded
An unexpected internal exception occurred. Please see log for detail.
Plug-in Provider:Eclipse.org
Plug-in Name:BIRT Designer UI
Plug-in ID:org.eclipse.birt.report.designer.ui
Version:2.2.1.r22a_v20071101
Error Code:Error.GUIException.invokedByUnexpectedException
Error Message:Caused by java.lang.IllegalArgumentException.
-I have tried to load the images separately ("image_1.gif" and "image_2.gif"), without condition, and do not have any problem.
-There is some way of doing something similarly in BIRT report desginer 2.2.1 or where the mistake can be?
Find more posts tagged with
Comments
JMaleski
I'm not sure if this is exactly what you are looking for, but it illustrates one way to accomplish the dynamic image:<br />
<br />
<a class='bbc_url' href='
http://download.eclipse.org/birt/downloads/examples/reports/Image/Image.html'>http://download.eclipse.org/birt/downloads/examples/reports/Image/Image.html</a>
;
JMaleski
Sorry for the multi post, but found another good link for you:<br />
<br />
<a class='bbc_url' href='
http://digiassn.blogspot.com/2007/12/birt-dynamic-images.html'>http://digiassn.blogspot.com/2007/12/birt-dynamic-images.html</a><br
/>
<br />
I think this example is closer to what you are trying to accomplish.
javi82
Thanks JMaleski for all.<br />
<br />
In <a class='bbc_url' href='
http://digiassn.blogspot.com/2007/12...ic-images.html'>http://digiassn.blogspot.com/2007/12...ic-images.html</a>
; it is what I want to do, except for a thing, I do not want to use a report parameter in the condition, I want use an expression extracted of the information of the data report. for example, if an customer has bougth 2 products that shows an image and if has bougth 4 products shows other one.
JMaleski
Just change
if (params["imageSelector"] == 0)
to
if(row["ROWNAME"] > value)
and it should work for you to compare row values instead of report params.
JMaleski
Again with the double posts : /
Anyway, I attached a quick dummy .rptdesign file along with a happy.bmp and sad.bmp. Just setup the resource folder and throw the images in there, it should be a quick example of how to change the image that is being displayed based on variables in the report.
Regards
javi82
Thanks very much, JMaleski.
This it`s all I need and works very well.
I was not using the method onRender on script tab.
Thanks.