You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by David Siefert <si...@gmail.com> on 2010/08/26 21:24:40 UTC
equality of Long object in template (velocity-1.3)
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
Re: equality of Long object in template (velocity-1.3)
Posted by David Siefert <si...@gmail.com>.
On Thu, Aug 26, 2010 at 2:52 PM, David Siefert <si...@gmail.com>wrote:
> On Thu, Aug 26, 2010 at 2:49 PM, Michael <sg...@gmx.net> wrote:
>
>> David Siefert schrieb:
>>
>> Hi All-
>>>
>>> I'm using velocity 1.3 and am generating some text from a template that
>>> has
>>> the following code:
>>>
>>
>> 1.3? This version is really old...
>> Did you try at least 1.6.x?
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
>> For additional commands, e-mail: user-help@velocity.apache.org
>>
>>
> I could give it a shot--in the meantime, what kind of risk would that
> present to my group in upgrading from 1.3 to 1.6? I've only written a few
> automated tests checking some templates, so the others remain 'unknown'
> whether or not they will generate correctly or contain errors after the
> upgrade.
>
> -David
>
With 1.6.4, both methods work (==1, =='1') which is awesome!
Thanks for the help!
-David
Re: equality of Long object in template (velocity-1.3)
Posted by David Siefert <si...@gmail.com>.
On Thu, Aug 26, 2010 at 2:58 PM, Michael <sg...@gmx.net> wrote:
> David Siefert schrieb:
>
> On Thu, Aug 26, 2010 at 2:49 PM, Michael <sg...@gmx.net> wrote:
>>
>> David Siefert schrieb:
>>>
>>> Hi All-
>>>
>>>> I'm using velocity 1.3 and am generating some text from a template that
>>>> has
>>>> the following code:
>>>>
>>>> 1.3? This version is really old...
>>> Did you try at least 1.6.x?
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
>>> For additional commands, e-mail: user-help@velocity.apache.org
>>>
>>>
>>> I could give it a shot--in the meantime, what kind of risk would that
>> present to my group in upgrading from 1.3 to 1.6? I've only written a few
>> automated tests checking some templates, so the others remain 'unknown'
>> whether or not they will generate correctly or contain errors after the
>> upgrade.
>>
>
> I can't exactly tell, you can check the changes report [1]
>
> [1]
> http://velocity.apache.org/engine/releases/velocity-1.6.4/changes-report.html
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> For additional commands, e-mail: user-help@velocity.apache.org
>
>
Thanks for the resource, and again for the help.
-David
Re: equality of Long object in template (velocity-1.3)
Posted by Michael <sg...@gmx.net>.
David Siefert schrieb:
> On Thu, Aug 26, 2010 at 2:49 PM, Michael <sg...@gmx.net> wrote:
>
>> David Siefert schrieb:
>>
>> Hi All-
>>> I'm using velocity 1.3 and am generating some text from a template that
>>> has
>>> the following code:
>>>
>> 1.3? This version is really old...
>> Did you try at least 1.6.x?
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
>> For additional commands, e-mail: user-help@velocity.apache.org
>>
>>
> I could give it a shot--in the meantime, what kind of risk would that
> present to my group in upgrading from 1.3 to 1.6? I've only written a few
> automated tests checking some templates, so the others remain 'unknown'
> whether or not they will generate correctly or contain errors after the
> upgrade.
I can't exactly tell, you can check the changes report [1]
[1]
http://velocity.apache.org/engine/releases/velocity-1.6.4/changes-report.html
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org
Re: equality of Long object in template (velocity-1.3)
Posted by David Siefert <si...@gmail.com>.
On Thu, Aug 26, 2010 at 2:49 PM, Michael <sg...@gmx.net> wrote:
> David Siefert schrieb:
>
> Hi All-
>>
>> I'm using velocity 1.3 and am generating some text from a template that
>> has
>> the following code:
>>
>
> 1.3? This version is really old...
> Did you try at least 1.6.x?
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> For additional commands, e-mail: user-help@velocity.apache.org
>
>
I could give it a shot--in the meantime, what kind of risk would that
present to my group in upgrading from 1.3 to 1.6? I've only written a few
automated tests checking some templates, so the others remain 'unknown'
whether or not they will generate correctly or contain errors after the
upgrade.
-David
Re: equality of Long object in template (velocity-1.3)
Posted by Michael <sg...@gmx.net>.
David Siefert schrieb:
> Hi All-
>
> I'm using velocity 1.3 and am generating some text from a template that has
> the following code:
1.3? This version is really old...
Did you try at least 1.6.x?
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org
Re: equality of Long object in template (velocity-1.3)
Posted by Will Glass-Husain <wg...@gmail.com>.
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 <sc...@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
>
>
Re: equality of Long object in template (velocity-1.3)
Posted by "B. Scott Smith" <sc...@smithdomain.com>.
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