A couple of brain cells died on me earlier today, so for some reason I couldn't get the solution I already had working before. Here's a quick one that does work, but only if you know the max number of elements your list will have.
In your ActionForm, declare your field as an array of String, and initialize it in your reset() method: public class SomeForm extends ActionForm { String[] names; public String[] getNames() { return names; } public void setNames(String[] names) { this.names = names; } public void reset(ActionMapping mapping, HttpServletRequest request) { names = new String[5]; } } In your form, you can reference them one by one: <html:form action="/submitForm"> Name 0: <html:text property="names[0]"/><br/> Name 1: <html:text property="names[1]"/><br/> Name 2: <html:text property="names[2]"/><br/> Name 3: <html:text property="names[3]"/><br/> Name 4: <html:text property="names[4]"/><br/> <html:submit/> </html:form> Your action can then access them upon submission: public ActionForward execute(ActionMapping mapping, ActionForm actionForm, HttpServletRequest request, HttpServletResponse response) throws Exception { SomeForm form = (SomeForm) actionForm; for (int i = 0; i < form.getNames().length; i++) { String name = form.getNames()[i]; System.out.println("Name[" + i + "]=" + name); } return null; } I know this works because I just tried it, just now. Like I said, my mind isn't fully functional right now, so I'll leave it to you to figure out the <logic:iterate> part. I believe as long as your array is accessible up to the number of rows you'll see, you'll be okay even though you don't know how many rows you'll show each time. Hope this gets you going. --- Andrew Close <[EMAIL PROTECTED]> wrote: > Hubert, > > i had previously read the indexprops article in the faq. i think i > have that part working. the second article was helpful, but i'm still > a bit confused. > when submitting my form. does my actionform need to have an array of > beans in it for the textfields? or can i just use an array of > strings? > if it needs an array of beans it seems silly to create a bean that has > a getter and setter for one string... although, i haven't been able > to get it to work either way. > i guess the question i have is how do i create an actionform that > contains lists of data? i'd prefer not to use DynaActionForms as the > article suggests because they got me into trouble once before. :) > > i'd look through the mailing list archives if they were searchable. > but as i noted in my previous post i keep getting the message 'Text > search not available for this list'. > > andy > > On Fri, 30 Jul 2004 11:32:25 -0700 (PDT), Hubert Rabago > <[EMAIL PROTECTED]> wrote: > > The problem is that Struts tries to populate your form, it starts with an > > empty collection. Take a look at LazyList (search the mailing list > > archives), or pre-initialize your form and put it in session scope. > > > > For more info, read http://struts.apache.org/faqs/indexedprops.html and > > http://www.developer.com/java/other/article.php/2233591. > > > > --- Andrew Close <[EMAIL PROTECTED]> wrote: > > > > > hi all, > > > > > > i'm having a hard time getting data from multiple textfields with > > > similar names out of a form and into my actionform. > > > in my JSP i'm using a [logic:iterate] tag to display (up to) ten > > > textfields. these textfields are initially empty. the user enters > > > data into the text fields and hits 'add', and i get an > > > IndexOutOfBoundsException. this exception isn't occuring in my code, > > > but i'm sure it's due to something i'm doing (or not doing) in my > > > code. > > > my action form has a Collection variable named itms that is an > > > ArrayList. the getter returns a Collection and the setter takes an > > > array of Strings, iterates through them and puts them into the > > > ArrayList. although i never get to that point. > > > i'm sure that my actionform is to blame and whatever Struts does > > > behind the scenes to populate my actionform is blowing up. > > > > > > i've looked at a couple of Ted Husteds articles (most notably: Use an > > > array to capture multiple parameters) but they don't seem to deal with > > > getting data out of the page form and into the action form. i've also > > > tried to search the mailing list archives but i keep getting the > > > message 'Text search not available for this list'... > > > > > > any pointers or suggestions on correctly setting up an actionform to > > > retrieve data from textfields that were built with an iterator? > > > > > > thanks > > > andy > > > __________________________________ Do you Yahoo!? New and Improved Yahoo! Mail - 100MB free storage! http://promotions.yahoo.com/new_mail --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]