You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Sara Frongillo <s....@itsys.it> on 2003/10/14 13:59:18 UTC

load array vtl

Hello,

I have a problem to load a ArrayList in velocity template, in Velocity Servlet I have:

          ArrayList images = new ArrayList();
          ArrayList audios = new ArrayList();
          ArrayList videos = new ArrayList();

          context.put("images", images);
          context.put("audios", audios);
          context.put("videos", videos);

and into Template I use them as follow:

   #foreach($item in $info) 
  #if($item.getDescrTipoInfoMultimediale().equals("Foto"))
     $images.add($item)
  #end
   #if($item.getDescrTipoInfoMultimediale().equals("Audio"))
   $audios.add($item)
  #end
   #if($info.getDescrTipoInfoMultimediale().equals("Video"))
     $videos.add($item)
  #end
    #end

but add() method add only 1 object and no more (if there are).

Will appreciate if someone can help or suggest me a method for load a array in VTL

_________________________________
Sara Frongillo
Software Area

I.T.Sys srl 
C.so Garibaldi, 215
84125 Salerno - Italy

Office +390892580977
Email s.frongillo@itsys.it
Web http://www.nexsoft.it 

Re: load array vtl

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
On Tuesday, October 14, 2003, at 07:59 AM, Sara Frongillo wrote:

> Hello,
>
> I have a problem to load a ArrayList in velocity template, in Velocity 
> Servlet I have:
>
>           ArrayList images = new ArrayList();
>           ArrayList audios = new ArrayList();
>           ArrayList videos = new ArrayList();
>
>           context.put("images", images);
>           context.put("audios", audios);
>           context.put("videos", videos);
>
> and into Template I use them as follow:
>
>    #foreach($item in $info)
>   #if($item.getDescrTipoInfoMultimediale().equals("Foto"))
>      $images.add($item)
>   #end
>    #if($item.getDescrTipoInfoMultimediale().equals("Audio"))
>    $audios.add($item)
>   #end
>    #if($info.getDescrTipoInfoMultimediale().equals("Video"))
>      $videos.add($item)
>   #end
>     #end
>
> but add() method add only 1 object and no more (if there are).
>
> Will appreciate if someone can help or suggest me a method for load a 
> array in VTL
>

This looks fine.  Why not throw some debugging in the template and do 
some output near each $<array>.add() - then you know what is getting 
selected as what...

> _________________________________
> Sara Frongillo
> Software Area
>
> I.T.Sys srl
> C.so Garibaldi, 215
> 84125 Salerno - Italy
>
> Office +390892580977
> Email s.frongillo@itsys.it
> Web http://www.nexsoft.it
>
-- 
Geir Magnusson Jr                                   203-247-1713(m)
geirm@optonline.net


---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org