• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Struts 2 iterate over an arraylist of T.O.

 
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello all, I am trying iterate over an arraylist of to's in struts 2 and I am not sure of the syntax and can't find any documentation that makes sense. The field needs to be editable.

phoneList is my array list.
CWAPhoneNumberTO is my TO.

Here is my jsp snippet:
<s:iterator value="phoneList" status="CWAPhoneNumberTO">
<tr>
<td style="width: 17%";>
<p>Phone info is: <s:textfield value="areaCode"/></p>
</td>
</tr>
</s:iterator>

Thanks in advance.
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I agree that Struts 2 documentation leaves a lot to be desired. However, I've found that one of the best ways to learn what it can do is by example. The struts2-showcase-2.0.9.war file that comes with the download is a treasure trove of Struts 2 sample code. You will find an example of a list of input fields in editPerson.jsp and its associated classes.
 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think you can try out this way :

<s:iterator value="phoneList" status="CWAPhoneNumberTO">
<tr>
<td style="width: 17%";>
<p>Phone info is: <s roperty value="areaCode"/></p>
</td>
</tr>
</s:iterator>

then it would be displayed on the table but i dont know how to do that for yr textbox the above code will display the content of yr arraylist on the table may be it can help you

Regards,
Rahul
 
Katie Doody
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you both. Thanks for the suggestion Merrill, I am in business again!
 
Katie Doody
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just if anyone searches for the answer:

<th>ID</th>
<th>Area Code</th>
<th>Phone Number</th>
</tr>
<s:iterator id="p" value="phoneList" status="CWAPhoneNumberTO">
<tr>
<td>
<s roperty value="%{id}" />
</td>
<td>
<s:textfield label="Area Code" name="phoneList(%{id}).areaCode" value="%{areaCode}" theme="simple" />
</td>
<td>
<s:textfield label="Phone Number" name="phoneList(%{id}).phoneNbr" value="%{phoneNbr}" theme="simple"/>
</td>
</tr>
</s:iterator>
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, I've been fighting with this many hours jajajaj, finally this works for me.

Specificly renders the content of an ArrayList, not more. I belive that you could use check boxes or something instead textfields, but i haven't tried Good Luck!


<s:iterator id="p" value="vecky" status="indice">
<s:set name="fon" value="vecky[#indice.index]"/>
<s:textfield label="Telefono" value="${fon}"name="vecky" />
</s:iterator>
 
reply
    Bookmark Topic Watch Topic
  • New Topic