velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "B. Scott Smith" <sc...@smithdomain.com>
Subject Re: equality of Long object in template (velocity-1.3)
Date Thu, 26 Aug 2010 20:18:54 GMT
  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: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org


Mime
View raw message