You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Ezequiel Puig <e....@vivacances.fr> on 2007/04/03 14:26:36 UTC

[s2] Tag iteration with Array

 

Hi people,

 

I am trying to iterate over an array.

 

In my action, i have defined:

 

Private String[] myArray;

 

public String[] get MyArray () {

return myArray;

}

public void setMyArray (String[] myArray) {

            this.myArray = myArray;

}

 

in the jsp, i am trying to acces to every entry:

 

I have tried that:

 

<s:iterator value="myArray" status="status">

<label><input type="checkbox" name="aa" id="aa" checked="checked" /><s:property value="myArray[0]"/></label>

</s:iterator>

 

And it's working (in my action i have give some values to the array). I am getting every time the same value. Normal.

 

But i am interested in iterate over the array, so i have tried this:

 

<s:iterator value="myArray" status="status">

<label><input type="checkbox" name="aa" id="aa" checked="checked" /><s:property value="myArray[status.index]"/></label>

</s:iterator>

 

Surprinsigly, it's not working.

 

Do you konw how I can access to the values from the array??

 

Thanks!

 

Ezequiel Puig
Developer
13, rue Camille Desmoulins 
92441 Issy-les-Moulineaux Cedex
Tél. +33 (0) 1 58 04 23 63
  
Vivacances - une marque du groupe européen Opodo.

Vols, séjours, week-ends, hôtels, locations, voitures, assurances.
www.vivacances.fr <http://www.vivacances.fr/>  

The information in this e-mail is confidential and may be legally privileged. It is intended solely for the addressee. Access to this e-mail by anyone else is unauthorised. If you are not the intended recipient, any disclosure, copying, distribution or any action taken or not taken in reliance on it is prohibited and may be unlawful. If you receive this e-mail in error, please delete it and notify us by return. 

 


Re: [s2] Tag iteration with Array

Posted by Dave Newton <ne...@yahoo.com>.
--- Ezequiel Puig <e....@vivacances.fr> wrote:
> <s:iterator value="myArray" status="status">
>   <s:property value="myArray[status.index]"/>
> </s:iterator>

See if

<s:iterator value="myArray">
  <s:property/>
</s:iterator>

works.

d.



 
____________________________________________________________________________________
Expecting? Get great news right away with email Auto-Check. 
Try the Yahoo! Mail Beta.
http://advision.webevents.yahoo.com/mailbeta/newmail_tools.html 

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