velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rich Garabedian" <r...@autorevenue.com>
Subject RE: List of Object Arrays
Date Tue, 07 Mar 2006 13:44:10 GMT
Thanks again for the note. Nice that we have choices, I ended up doing this
based on Nathan's advise:

 

#foreach( $appt in $apptList ) 

   #foreach ($item in $appt)

 

      #if ($velocityCount == 1) 

         #set($APT = $item)

      #elseif ($velocityCount == 2) 

         #set($A = $item) 

      #elseif ($velocityCount == 3)

         #set($V = $item)

       #elseif ($velocityCount == 4) 

         #set($C = $item) 

       #end

 

    #end

 

    ## Do stuff with $A, $V, $C, or $APT

#end

 

  _____  

From: Bill Rishel [mailto:illusyn@gmail.com] 
Sent: Monday, March 06, 2006 7:11 PM
To: Velocity Users List; richg@autorevenue.com
Subject: Re: List of Object Arrays

 

OK, if you have to access the array items by index
number then use the ListTool:

Make sure you have the latest tools jar. Then put:

 <tool>
   <key>list</key>
   <scope>application</scope>
   <class>org.apache.velocity.tools.generic.ListTool</class>
 </tool>

into your toobox.xml

Then you can do:

#foreach ($array in $arrayList)
    #set($table1 = $list.get($array,0))
    #set($table2 = $list.get($array,1))
    #set($table3 = $list.get($array,2))

## etc.

#end

The "$list" is the handle to access the ListTool functionality.

Bill

On 3/6/06, Rich Garabedian <rich@autorevenue.com> wrote:

Hey Bill.

Thanks so much for the note.

I don't think that code skeleton will for me because the objects in the
object array will be different. The List of object arrays is coming to me
from hibernate and in this particular scenario I'll have three different 
beans. What I really want to do is something like this:

#foreach ($array in $arrayList)
    #set($table1 = $array.get(0))
    #set($table2 = $array.get(1))
    #set($table3 = $array.get(2))

    ## Do stuff with $table1 
    ## Do stuff with $table2
    ## Do stuff with $table3
#end

But I couldn't get that to work

-----Original Message-----
From: Bill Rishel [mailto:illusyn@gmail.com  <mailto:illusyn@gmail.com> ]
Sent: Monday, March 06, 2006 3:06 PM
To: Velocity Users List; richg@autorevenue.com
Subject: Re: List of Object Arrays

#foreach ($array in $arrayList)
    #foreach ($item in $array) 
       $item ## do something with  $item
    #end
#end


Bill


On 3/5/06, Rich Garabedian <rich@autorevenue.com> wrote:
>
> Greetings Users List. 
>
> Is there any way to loop through a List of Object Arrays in Velocity? In
> other words:
>
> Iterator i = myList.iterator();
>
> while(i.hasNext())
> {
>     Object[] configArray = (Object[]) i.next();
>
>     //Do something with object array
> }
>
>
>
> ---------------------------------------------------------------------
> 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

 


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message