Dynamically Creating Image URL's using iReport

0

I am trying to take a database value and append a .png a the end to create the path to an image using iReport.

If it was html the equivalent would be

<img src ="http://someurl.com/${databasevalue}.png"/>

I am using iReport 3.1.2

Thanks in advance.

 

clhubert's picture
Joined: Nov 24 2007 - 5:35am
Last seen: 3 years 2 months ago

4 Answers:

0

It seems like the solution is to use the imageExpression tag.  

                <image hyperlinkType="None">
                    <reportElement x="370" y="2" width="42" height="17"/>
                    <imageExpression class="java.lang.String"><![CDATA["http://www.translatorscafe.com/cafe/images/flags/US.gif"]]></imageExpres...
                </image>

But I am having trouble adjusting it so that it changes per row.

So far I tried...

                <image hyperlinkType="None">
                    <reportElement x="370" y="2" width="42" height="17"/>
                    <imageExpression class="java.lang.String"><![CDATA["http://www.translatorscafe.com/cafe/images/flags/"$F{Country_ISO3166}".gif"]]></imageExpression>
                </image>

 

But there appears to be an error with the expression.  Any help would be appreciated.

clhubert's picture
Joined: Nov 24 2007 - 5:35am
Last seen: 3 years 2 months ago
0

I got it working, just needed to you the "+".   Like so...

 

"http://www.translatorscafe.com/cafe/images/flags/"+ $F{Country_ISO3166} +".gif"

clhubert's picture
Joined: Nov 24 2007 - 5:35am
Last seen: 3 years 2 months ago
0
Good morning clhubert Is this what you are doing??? I am still getting xml errors.
lconklin's picture
Joined: Dec 3 2008 - 10:34am
Last seen: 11 years 1 week ago
0

What I posted earlier is just the expression I used in iReport.   The actual XML is the following.

<image onErrorType="Blank" hyperlinkType="None">
<imageExpression class="java.lang.String">

<![CDATA["http://www.translatorscafe.com/cafe/images/flags/"+$F{Country_ISO3166} +".gif"]]>

</imageExpression>

</image>

 

clhubert's picture
Joined: Nov 24 2007 - 5:35am
Last seen: 3 years 2 months ago
Feedback
randomness