Re: null in velocity

2004-12-02 Thread Edgar Poce
The condition is evaluated to determine if it's a boolean (true/false) 
or if it's not null.

#if ($car.fuel)
...
#end
Regards
Edgar
Check http://jakarta.apache.org/velocity/user-guide.html#Conditionals
THE ULTIMATE SUBBIAH wrote:
How to check for null in velocity
for eg. I load a class in the context Class:: car
#if ($car.getFuel() = null ?? )
This does not work.
Thx
_
The happening world of BPO! Know all that you need to know! 
http://www.bpowatchindia.com/msn/ Keep in step with whats hot!

-
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]


Re: null in velocity

2004-12-02 Thread Shinobu Kawai
Hi SUBBIAH,

 How to check for null in velocity
 for eg. I load a class in the context Class:: car
 
 #if ($car.getFuel() = null ?? )

You can use NullTool
  http://wiki.apache.org/jakarta-velocity/NullTool

#if ($null.isNull($car.fuel))

Best regards,
-- Shinobu Kawai

-- 
Shinobu Kawai [EMAIL PROTECTED]

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



Re: null in velocity

2004-12-02 Thread Terry Steichen
I think you can also do something like this:

#if($car  $car == )

That is, if $car is defined and has no value (ie, null)
  - Original Message - 
  From: Shinobu Kawai 
  To: Velocity Users List 
  Sent: Thursday, December 02, 2004 10:56 AM
  Subject: Re: null in velocity


  Hi SUBBIAH,

   How to check for null in velocity
   for eg. I load a class in the context Class:: car
   
   #if ($car.getFuel() = null ?? )

  You can use NullTool
http://wiki.apache.org/jakarta-velocity/NullTool

  #if ($null.isNull($car.fuel))

  Best regards,
  -- Shinobu Kawai

  -- 
  Shinobu Kawai [EMAIL PROTECTED]

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



Re: null in velocity

2004-12-02 Thread Nathan Bubna
I find #if( $!car ==  ) to be the most reliable null test.

On Thu, 2 Dec 2004 14:47:29 -0500, Terry Steichen [EMAIL PROTECTED] wrote:
 I think you can also do something like this:
 
 #if($car  $car == )
 
 That is, if $car is defined and has no value (ie, null)
 
 
   - Original Message -
   From: Shinobu Kawai
   To: Velocity Users List
   Sent: Thursday, December 02, 2004 10:56 AM
   Subject: Re: null in velocity
 
   Hi SUBBIAH,
 
How to check for null in velocity
for eg. I load a class in the context Class:: car
   
#if ($car.getFuel() = null ?? )
 
   You can use NullTool
 http://wiki.apache.org/jakarta-velocity/NullTool
 
   #if ($null.isNull($car.fuel))
 
   Best regards,
   -- Shinobu Kawai
 
   --
   Shinobu Kawai [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]



Re: null in velocity

2004-12-02 Thread Barbara Baughman
If you are doing a test for java 'null' value, then
#if ($car.fuel)
will return true if $car.fuel is NOT a java null value.

If you are checking for an empty string, then use the String
comparison.

#if ($car.fuel==)

If you want to check for both:
#if ($!car.fuel==)

I have a general purpose tool with a method that checks for null or
empty or all blanks and include the tool object in all Velocity
contexts.

#if ($tool.isEmpty($car.fuel))

You may have a different requirement that would require a special
method.  Perhaps you want it to return false if fuel is null or empty
or the value 0.  Then you would have to create your own method in the
$car object.

#if ($car.hasFuel())

BTW, always use '==' instead of '=' when making comparisons in
Velocity.

Barbara Baughman
X2157

On Thu, 2 Dec 2004, THE ULTIMATE SUBBIAH wrote:

 How to check for null in velocity
 for eg. I load a class in the context Class:: car

 #if ($car.getFuel() = null ?? )

 This does not work.
 Thx

 _
 The happening world of BPO! Know all that you need to know!
 http://www.bpowatchindia.com/msn/ Keep in step with whatÂ’s hot!


 -
 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]