views:

101

answers:

1

Hi,

What is the syntax for an not true or false if statement in nVelocity (or Velocity)?

And more importantly, where is this in the nVelocity docs? I've been Googling for quite a while to no avail.

I've tried several different combinations such as:

#if (!$artist.IsFestival)

$artist.FestivalName

#end

and

#if ($artist.IsFestival == false)

$artist.FestivalName

#end

So frustrating!

Thanks in advance!

-Ev

A: 

Both of these should have worked, so I think you may have a problem accessing "isFestival". You should try the bean syntax $artist.festival or the method syntax $artist.isFestival() (you are now using a mix of both). The method returns a boolean, right?

For debugging try to just print out the result to see if it works:

 $artist            ## see if the artist is defined
 $artist.IsFestival  ## maybe an error   
 $artist.festival    ## should be true or false
 $artist.isFestival() ## should be true or false

Update: Just read that you are asking about nVelocity. It is possible that my answer only applies to the Java version. Give it a try anyway.

Thilo
True for NVelocity too
Isaac Cambron
Ah thanks a lot.But I what I really need to know if how to negate the test, so the if something is _not_ true. How do I say: if (NOT $artist.IsFestival)?
Ev
Both of the patterns you showed should work (`!$x` and `$x == false`).
Thilo
Thanks a lot - I'll check to make sure the property is set to the right value
Ev