velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christoph Reck <Christoph.R...@dlr.de>
Subject Re: String array
Date Wed, 07 Mar 2001 13:31:57 GMT
One ugly Java caveat is that a Set or an Object[] cannot be
easily converted to an String[], event thou they contain 
purely Strings.

So if you change your method signature either:
A) getList(int, Object[])
   and use it $util.getList( $rows, $attrs.toArray() )
B) getList(int, Set) or getList(int, ArrayList)
   and use it in a straightforward manner $util.getList($rows, $attrs)

:) Chirstoph Reck

"Geir Magnusson Jr." wrote:
> 
> Andreas Wikberger wrote:
> >
> > Hello,
> >
> > I have a problem with passing a String array as a parameter to a
> > predefined java method from my velocity template.
> >
> > I have a java class in my Context called $util. In this class I have a
> > method as follows:
> >
> > public void getList(int noOfRows, String [] attrs){
> >   ...
> > }
> >
> > >From my velocity template I call this method like this:
> >
> > ...
> > #set( $rows = 5)
> > #set( $attrs = ["name","phone"])
> > $util.getList($rows, $attrs)
> > ...
> 
> $attrs is an ArrayList, not a String[].
> 
> The array and range operators :
> 
> ["a","b"]  or [1..10]
> 
> both return a java.util.ArrayList
>[snip]
> Just change your method, or add one as a wrapper that takes an array
> list and calls the orignal one, and all should be fine.

Mime
View raw message