velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jonathan Ihm <jonathan....@gmail.com>
Subject Re: Problems with #set($var = $x - $a.func("$z"))${var}
Date Wed, 24 Aug 2011 19:57:53 GMT
You would have to parse the string #set($Integer = 1) and then do
$Integer.parse($x)

On Wed, Aug 24, 2011 at 2:51 PM, Alec Swan <alecswan@gmail.com> wrote:
> Ah, looks like $x type is a string even though it represents a number.
>  Is there any type casting in Velocity?
>
> On Wed, Aug 24, 2011 at 1:46 PM, Nathan Bubna <nbubna@gmail.com> wrote:
>> what are the types of $x and $a.func("$z") ?
>>
>> subtraction only works on java.lang.Number (or primitive counterparts)
>> or objects that implement Velocity's TemplateNumber interface.
>>
>> On Wed, Aug 24, 2011 at 12:33 PM, Alec Swan <alecswan@gmail.com> wrote:
>>> Hello,
>>>
>>> I am having problems with getting the following expression to work correctly:
>>> #set($var = $x - $a.func("$z"))${var}
>>>
>>> Note that the following expressions work properly:
>>> #set($var = $x)${var}
>>> #set($var = $a.func("$z"))${var}
>>>
>>> However, subtraction does not seem to return the expected result.
>>>
>>> Thanks,
>>>
>>> Alec
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
>>> For additional commands, e-mail: user-help@velocity.apache.org
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
>> For additional commands, e-mail: user-help@velocity.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> For additional commands, e-mail: user-help@velocity.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org


Mime
View raw message