You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by William Lee <wl...@sendmail.com> on 2002/11/19 20:50:02 UTC

Passing in an array as a Java function argument?

Is there a way in velocity to pass in an array list defined in Velocity 
as a function parameter?

For example, can I have:

#set ($arr = ["blah", "blah", "blah"])
#set ($result = $tool.foo($arr))

?

If I can do the aboved, what's the signature of the "foo" function of 
the tool instance $tool?  Is it List, ArrayList, Object[], String[], or 
something else?

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


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Passing in an array as a Java function argument?

Posted by "Geir Magnusson Jr." <ge...@adeptra.com>.
On Tuesday, November 19, 2002, at 03:07 PM, Andy Lee wrote:

> At 11:50 AM -0800 11/19/02, William Lee wrote:
>> Is there a way in velocity to pass in an array list defined in 
>> Velocity as a function parameter?
>>
>> For example, can I have:
>>
>> #set ($arr = ["blah", "blah", "blah"])
>> #set ($result = $tool.foo($arr))
>>
>> ?
>
> Yes.
>
>> If I can do the aboved, what's the signature of the "foo" function of 
>> the tool instance $tool?  Is it List, ArrayList, Object[], String[], 
>> or something else?
>
> If I recall correctly, $arr will be an instance of ArrayList.  A quick 
> way to check is to add its class name to the template and reload the 
> template.  I think I used something like:
>
>    $arr.getClass().getName()

Yes - it is an ArrayList.

-- 
Geir Magnusson Jr                                   203-355-2219(w)
Adeptra, Inc.                                       203-247-1713(m)
geirm@adeptra.com


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Passing in an array as a Java function argument?

Posted by Andy Lee <ag...@earthlink.net>.
At 11:50 AM -0800 11/19/02, William Lee wrote:
>Is there a way in velocity to pass in an array list defined in 
>Velocity as a function parameter?
>
>For example, can I have:
>
>#set ($arr = ["blah", "blah", "blah"])
>#set ($result = $tool.foo($arr))
>
>?

Yes.

>If I can do the aboved, what's the signature of the "foo" function 
>of the tool instance $tool?  Is it List, ArrayList, Object[], 
>String[], or something else?

If I recall correctly, $arr will be an instance of ArrayList.  A 
quick way to check is to add its class name to the template and 
reload the template.  I think I used something like:

    $arr.getClass().getName()

--Andy

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>