The following example will show one of two logos, depending on the value of a report parameter. If the value is equal to 0, we will show the Eclipse logo at
http://www.eclipse.org/eclipse.org-common/themes/Phoenix/images/eclipse_home_header.jpg
If the value is 1, we will show the BIRT Exchange logo:
http://www.birt-exchange.com/themes/birt/images/homep_r1_c1.gif
This image will reside in the Master Page of the report. So lets take a look at how to do this.
- First, create a new report called DynamicImage.rptDesign
Figure 1. Create new Report
- In the new report design, open up the Master Page tab.
- Drag over a grid, and make it 2 column, 1 row.
- In the 1st column, drag over an Image component.
- For the URL, put in “http://www.eclipse.org/eclipse.org-common/themes/Phoenix/images/eclipse_home_header.jpg”. Be sure to keep the quotes. This is more as a place holder than anything else.
Figure 2. Master Page with Image
- Create a new report parameter called imageSelector. It needs to be an Integer type. In the following screen shot, I am using a List Box and a List of Values for this purpose.
Figure 3. Create new Parameter
- Select the Image.
- Open the Script tab in the Report Designer
- Change the Event to onRender.
- Use the following BIRT Script
if (params["imageSelector"] == 0)
{
this.setURL("http://www.eclipse.org/eclipse.org-common/themes/Phoenix/images/eclipse_home_header.jpg");
}
else
{
this.setURL("http://www.birt-exchange.com/themes/birt/images/homep_r1_c1.gif");
}
- Save and run.
When you set the value to Eclipse, it will show the Eclipse logo. When set to the BIRT Exchange, it will show that logo.
Figure 4. The Final Report
said...
that was alomst exactly was i was looking for. thx a lot.
i will have to choose a uri based on a value in my dataSet, so i need to access the dataSet from the script.. hope to find an example.
Jassi said...
how we can change image name dynamically for dynamic image



