velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Will Glass-Husain <wglasshus...@gmail.com>
Subject Re: equality of Long object in template (velocity-1.3)
Date Fri, 27 Aug 2010 03:39:05 GMT
Hi,

Since Velocity 1.5 comparison between different number types (integers,
longs, doubles, etc) is supported.

Backwards compatibility for all versions of Velocity is excellent.  The
language has some new features (map literals, decimal literals, macro
improvements) but all earlier templates will work in new versions.

There's some slight differences in the jar dependencies (upgraded versions
of commons-collection, etc).

WILL



On Thu, Aug 26, 2010 at 1:18 PM, B. Scott Smith <scott@smithdomain.com>wrote:

>  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
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message