File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes ArrayList in Struts Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "ArrayList in Struts" Watch "ArrayList in Struts" New topic

ArrayList in Struts

Anjali Krishnan

Joined: May 02, 2006
Posts: 7
Can someone please let me know if the way I am accessing ArrayList is correct way or not

I am using an ArrayList to store a list of String where the number of input changes.
My code ActionForm :
List numberList = new ArrayList();
public List getnumberList() {
return numberList;

public void setnumberList(List newnumberList) {
numberList = newnumberList;

public String getnumber(int index) {
if (numberList == null){

numberList = new ArrayList();
while (numberList.size() <= index){
return (String) numberList.get(index);
public void setnumber(int index, String number) {
if (numberList == null){

numberList = new ArrayList();
while (numberList.size() <= index){
numberList.set(index, number);

First time I Initilaize the ArrayList to show 20 input fields

while (numberList.size() < 20){

<logic:iterate id="number" indexId="numberCount"
<html:text name="form"
property='<%="number[" + index + "]"%>'

I agree. Here's the link:
subject: ArrayList in Struts
Similar Threads
Indexed tags and form beans
Indexed Setting/properties
bean cannot be found in any scope
Struts 1.2.9 +text areas.
Problem with IndexId attribute