In that old release, you can not compare Long values.
You can, however, convert to String, as you (almost) did.
This should work:

  #if ( "$model.getCount()" == "1" ) ... #end

or shorter:

  #if ( "$model.count" == "1" ) ... #end

also, != will work. But < or > will never work...
 - Scott

On 8/26/2010 3:24 PM, David Siefert wrote:
Hi All-

I'm using velocity 1.3 and am generating some text from a template that has
the following code:

#if ( $model.getCount() == 1 ) ... #end

The model object has method getCount() which returns Long (the primitive
wrapper object).  It seems this comparison is not happening correctly as the
"..." text is not included in the output.  I've also tried the following:

#if ( $model.getCount() == "1" ) ... #end

and

#if ( $model.getCount() == '1' ) ... #end

thinking that it might be calling toString on the Long object itself, but
this does not work either.  I've confirmed $model.getCount() on a line by
itself outputs the single '1' character in the generated text.

What would I need to do to get this conditional working?

Thanks,
David


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to