You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by di...@waterfind.com.au on 2006/03/02 04:02:41 UTC
RE:Array
Hello,
what would be the best way to read the item of an array one by one;
not like;
#foreach( $item in $result )
$item
#end
i want to read it like, array[2], reading the item two of an array? through the velocity,
i have try the $array.get($result,2), and it not working, its there is a another way?
--
This message was sent on behalf of dilan@waterfind.com.au at openSubscriber.com
http://www.opensubscriber.com/messages/velocity-user@jakarta.apache.org/topic.html
---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org
Re: Array
Posted by Bill Rishel <il...@gmail.com>.
yes...
Having the latest tools jar, just put:
<tool>
<key>list</key>
<scope>application</scope>
<class>org.apache.velocity.tools.generic.ListTool</class>
</tool>
into your toobox.xml
If the array you have put into your context is say $myArray,
the you can do: $list($myArray, $indexNum)
On the other hand, if you make your array into a Vector
and put that into the context, the you can do:
$myvector.elementAt($indexNum)
Bill
On 3/1/06, Nathan Bubna <nb...@gmail.com> wrote:
>
> get the latest velocity tools jar and put an instance of ListTool in
> the context:
>
>
> http://jakarta.apache.org/velocity/tools/javadoc/org/apache/velocity/tools/generic/ListTool.html
>
> On 3/1/06, dilan@waterfind.com.au <di...@waterfind.com.au> wrote:
> > Hello,
> > what would be the best way to read the item of an array one by one;
> > not like;
> > #foreach( $item in $result )
> > $item
> > #end
> >
> > i want to read it like, array[2], reading the item two of an array?
> through the velocity,
> > i have try the $array.get($result,2), and it not working, its there is a
> another way?
> >
> > --
> > This message was sent on behalf of dilan@waterfind.com.au at
> openSubscriber.com
> >
> http://www.opensubscriber.com/messages/velocity-user@jakarta.apache.org/topic.html
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: velocity-user-help@jakarta.apache.org
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: velocity-user-help@jakarta.apache.org
>
>
Re: Array
Posted by Nathan Bubna <nb...@gmail.com>.
get the latest velocity tools jar and put an instance of ListTool in
the context:
http://jakarta.apache.org/velocity/tools/javadoc/org/apache/velocity/tools/generic/ListTool.html
On 3/1/06, dilan@waterfind.com.au <di...@waterfind.com.au> wrote:
> Hello,
> what would be the best way to read the item of an array one by one;
> not like;
> #foreach( $item in $result )
> $item
> #end
>
> i want to read it like, array[2], reading the item two of an array? through the velocity,
> i have try the $array.get($result,2), and it not working, its there is a another way?
>
> --
> This message was sent on behalf of dilan@waterfind.com.au at openSubscriber.com
> http://www.opensubscriber.com/messages/velocity-user@jakarta.apache.org/topic.html
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: velocity-user-help@jakarta.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org