Yeah, #if ($needMoreInfo == 'Y' ) will only succeed if $needMoreInfo is in the context, is of type String, and has value "Y". Put a [$needMoreInfo] right before the if and see that you get a [Y] in your output. Also, try using a #set( $needMoreInfo = 'Y' ) right before the if... that should fix it so the needmoreinfo gif *always* shows up. That should convince you it's evaluating correctly-- likely your context isn't getting set correctly.

--jason

jian chen wrote:

Hi, Michael,

What did you pass in to the velocity context? I think it should be:
ctx.put("needMoreInfo", "Y");

Or, You could set it in another way in your java code:
ctx.put("needMoreInfo", Boolean.TRUE);
Then, in the Velocity template, you will put:

#if ($needMoreInfo)
 <img src="images/needmoreinfo.gif">
#else
 <img src="images/1x1.gif">
#end

Cheers,

Jian

On 5/31/05, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
Thanks Jian,
But the img src is correct I have tried several different things
And the if seems to always fall through to the else section even though I
know I
Have 2 conditions that meet the if condition.
I am very new to Velocity, can it be due to it be evaluated on the server?

-----Original Message-----
From: jian chen [mailto:[EMAIL PROTECTED]
Sent: Tuesday, May 31, 2005 3:14 PM
To: Velocity Users List
Subject: Re: Newbie needs help


It seems like an html issue with the img src url not correct.

Try putting some text in the if/else and see which one gets called.
Something like this:

#if ($needMoreInfo == 'Y' )
   ##<img src="images/needmoreinfo.gif">
   image is displayed here
#else
   ##<img src="images/1x1.gif">
   another image is here
#end

I suspect it maybe an issue with <img src=...> not having the correct URL.

Jian

On 5/31/05, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
I have a simple velocity question.

<span name="reportDataCell" datafld="needMoreInfo">

This line displays the value of my data field correctly it is either a Y
or
a blank space

I would like to display an image instead of the character
I have tried the following but it does not seem to work correctly.  Can
anyone tell me what I am doing wrong.

#if ($needMoreInfo == 'Y' )
  <img src="images/needmoreinfo.gif">
#else
  <img src="images/1x1.gif">
#end





-----------------------------------------
This message and any attachments are intended only for the use of the
addressee and may contain information that is privileged and confidential.
If the reader of the message is not the intended recipient or an
authorized
representative of the intended recipient, you are hereby notified that any
dissemination of this communication is strictly prohibited. If you have
received this communication in error, notify the sender immediately by
return email and delete the message and any attachments from your system.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to