You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@turbine.apache.org by William Lee <wl...@sendmail.com> on 2001/09/06 04:00:15 UTC

Velocity type casting?

I'm wondering if it's possible to do the following:

Define a class and function like:

class Foo
{
	public Object bar(String str, long n1, long n2);
}

In the velocity context I put an instance of Foo (say $foo).  I then
have in my velocity macro:

#set ($a = 3)
#set ($b = 4)
#set ($result = $foo.bar("blah", $a, $b))

I've tried to do something like the aboved but somehow the bar function
is never called.  The velocity log says the RHS of the last set
statement is null.  I'm just wondering how type casting work in
Velocity.  Is it actually possible to do the aboved?  Is there any way
to get around this?

Thanks,
-- 
William Lee (Will)        | Sendmail Inc.
Email:  wlee@sendmail.com | http://www.sendmail.com
Tel:    (510) 594-5505    |

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


Re: Velocity type casting?

Posted by John McNally <jm...@collab.net>.
Velocity only supports int.  It does not do number type conversions. 
There was just a long thread of discussion about a similar topic
(supporting floating point numbers).  It seemed most the developers of
Velocity are of the opinion that even supporting any numeric data was a
mistake they wish had been avoided, it was only in place to make
converting from WebMacro easier, and they are loathe to add any further
ability to use number literals in templates.

john mcnally  

William Lee wrote:
> 
> I'm wondering if it's possible to do the following:
> 
> Define a class and function like:
> 
> class Foo
> {
>         public Object bar(String str, long n1, long n2);
> }
> 
> In the velocity context I put an instance of Foo (say $foo).  I then
> have in my velocity macro:
> 
> #set ($a = 3)
> #set ($b = 4)
> #set ($result = $foo.bar("blah", $a, $b))
> 
> I've tried to do something like the aboved but somehow the bar function
> is never called.  The velocity log says the RHS of the last set
> statement is null.  I'm just wondering how type casting work in
> Velocity.  Is it actually possible to do the aboved?  Is there any way
> to get around this?
> 
> Thanks,
> --
> William Lee (Will)        | Sendmail Inc.
> Email:  wlee@sendmail.com | http://www.sendmail.com
> Tel:    (510) 594-5505    |
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: turbine-user-help@jakarta.apache.org

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