You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by "Thys De Wet@iCommerce" <th...@za.didata.com> on 2001/06/26 10:29:59 UTC

Multidimensional arrays?

Is there some way in which i can use vectors containing vectors  ?

I want to do something like :

#foreach ($object in $main)
	Hi $object.firstname
	Your application to register:
	$object.tradename#*
	*##foreach ($taxtype in $object.taxtype)#*
		*#$taxtype, #*
	*# has been $object.state
#end

would this work properly ??

I want it to print something like:

Hi Thys
Your application to register:
John Doe inc. for Paw-Paw, Banana has been succesful.



**********************************************************************

The information in this e-mail is confidential and is legally privileged.
It is intended solely for the addressee.  If this email is not intended for
you, you cannot copy, distribute, or disclose the included information
to any-one

If you are not the intended recipient please delete the mail. Whilst
all reasonable steps have been taken to ensure the accuracy and
integrity of all data transmitted electronically, no liability is accepted
if the data, for whatever reason, is corrupt or does not reach it's
intended destination.
All business is undertaken, subject to our standard trading conditions
which are available on request.

*******************************************************************

Re: Multidimensional arrays?

Posted by Christoph Reck <Ch...@dlr.de>.
Sure that should work if:
1. you add the #end directive for the second #foreach
2. your $object has a getTaxtype() method or is a map with a "taxtype" entry.
3. you add the output string "for" after the tradename

You can enhance the commas by adding to #set directives: 
#foreach( $object in $main )
  Hi $object.firstname
  Your application to register:
  $object.tradename for#*
  *##set( $sep = "" )#*
  *##foreach( $taxtype in $object.taxtype )#*
    *# $taxtype$sep#set( $sep = "," )#*
  *##end#*
  *# has been $object.state
#end

(Yuk! the ugly hacks that are necesarry to get nice whitespace output)

:) Christoph

"Thys De Wet@iCommerce" wrote:
> 
> Is there some way in which i can use vectors containing vectors  ?
> 
> I want to do something like :
> 
> #foreach ($object in $main)
>         Hi $object.firstname
>         Your application to register:
>         $object.tradename#*
>         *##foreach ($taxtype in $object.taxtype)#*
>                 *#$taxtype, #*
>         *# has been $object.state
> #end
> 
> would this work properly ??
> 
> I want it to print something like:
> 
> Hi Thys
> Your application to register:
> John Doe inc. for Paw-Paw, Banana has been succesful.