velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alexander <the.malk...@gmail.com>
Subject Re: checking if all variables are present
Date Tue, 28 Jul 2009 10:07:41 GMT
Maybe this will help you [?] This way I always test if variable is not null

http://velocity.apache.org/engine/devel/user-guide.html#Conditionals
.............

The *#if* directive in Velocity allows for text to be included when the web
page is generated, on the conditional that the if statement is true. For
example:


#if( $foo )
   <strong>Velocity!</strong>
#end

The variable *$foo* is evaluated to determine whether it is true, which will
happen under one of two circumstances: (i) *$foo* is a boolean (true/false)
which has a true value, or (ii)* the value is not null*. Remember that the
Velocity context only contains Objects, so when we say 'boolean', it will be
represented as a Boolean (the class). This is true even for methods that
return boolean - the introspection infrastructure will return a Boolean of
the same logical value.

............

2009/7/28 Captain Cid <captain_cid@indiatimes.com>

>
> I have a template containing some variables to be rendered from context.
> Is there way by which i can know if all the variables are present in the
> context, otherwise throw an error.
> --
> View this message in context:
> http://www.nabble.com/checking-if-all-variables-are-present-tp24696207p24696207.html
> Sent from the Velocity - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> For additional commands, e-mail: user-help@velocity.apache.org
>
>

Mime
  • Unnamed multipart/related (inline, None, 0 bytes)
View raw message