Thanks God. I thought people lost interest in this one and i am left alone.Man i am having a tough time with this. All these days because of this Indexoutofbond, when evenr we needed a List as form element,we used to go for actionForm unnecessary. I thought of cleaning up some code and thats how i started this. open action seems to be working as i am able to see the values populated in the open action in the jsp page. But when i click on the submit button "mytestjsppostaction.do" is called and i have break points in my dynaactionform as wel as in the first line of MyFormPost.java. The control first comes to the dyna actionform and then it seems like calling beanutil.populate where the exception is thrown. It never comes to the MyFormPost.java Thank-you, Manoj Mathew r > > > > I still get the same and agian nameList = null > > > > [Servlet Error]-[BeanUtils.populate]: > > java.lang.IndexOutOfBoundsException: Index: 4, Size: > > 0 > > at > > > c > > Mathew, > > Okay, forget about my previous email. Try this > > instead. I didn't look at your code that closely > > before. > > > > List mm = new ArrayList(); > > List nameList = ListUtils.lazyList(mm, new > > Factory() { > > public Object create() { > > return new String(); > > } > > }); > > set("friendName", nameList); > > > > Regards, > > > > Richard > > > > > > 1) define the the > > --- "Mathew, Manoj" > > wrote: > > > Richard > > > when i use that wasy i get this error > > > The following exception was logged > > > java.lang.NullPointerException: The type for > > > property friendName is invalid > > > at > > > > > > org.apache.struts.action.DynaActionForm.set(DynaActionForm.java:414) > > > > > > struts config > > > > > > > > type="org.apache.struts.action.DynaActionForm"> > > > > > > > > type="org.apache.commons.collections.ListUtils.LazyList" > > > /> > > > > > > Thank-you, > > > Manoj Mathew > > > GIS-Systems > > > (515-362-0539) > > > > > > > > > -----Original Message----- > > > From: Richard Yee [mailto:ryee86@yahoo.com] > > > Sent: Thursday, April 29, 2004 12:06 PM > > > To: Struts Users Mailing List > > > Subject: RE: ArrayList and DynaActionForm--need > > help > > > very badly > > > > > > > > > Mathew, > > > I think you are mixing the instructions that > > > everyone > > > has given you. If you use the LazyList as your > > > form-property type in your form-bean, then you > > don't > > > need to put this code, > > > > List mm = new ArrayList(); > > > > List nameList = ListUtils.lazyList(mm, new > > > > Factory() { > > > > public Object create() { > > > > return "fakeName"; > > > > } > > > > }); > > > > set("friendName", nameList); > > > > > > in your reset() method. In fact, you don't have to > > > put > > > any code that initializes your list because the > > > LazyList takes care of that for you. > > > > > > In the solution I proposed in my previous emails, > > I > > > told you to put the code in the reset method only > > > when > > > you are using the plain ArrayList or a simple > > array. > > > This code is necessary to prevent the index out of > > > bounds exception when you use these types with > > > indexed > > > properties. > > > > > > > > > Regards, > > > > > > Richard > > > --- "Mathew, Manoj" > > > wrote: > > > > Let me explain in detail > > > > > > > > I have a open action which just populate the > > > > list..and forwarded to my jsp > > > > > > > > public class MyTestOpenAction extends Action { > > > > public ActionForward execute(ActionMapping > > > mapping, > > > > ActionForm frm, > > > > javax.servlet.http.HttpServletRequest request, > > > > javax.servlet.http.HttpServletResponse response) > > > > throws Exception { > > > > > > > > myTestForm form = (myTestForm) frm; > > > > form.set("myName","Manoj Mathew"); > > > > form.set("friendName", getMyList()); > > > > return mapping.findForward("success"); > > > > } > > > > > > > > private List getMyList() { > > > > > > > > List myList = new ArrayList(); > > > > myList.add(0, "Jimmy"); > > > > myList.add(1, "Tom"); > > > > myList.add(2, "Jack"); > > > > myList.add(3, "Jack2"); > > > > myList.add(4, "Jack3"); > > > > return myList; > > > > } > > > > > > > > } > > > > > > > > and my jsp looks like this > > > > > > > > > > > > > > > action="mytestjsppostaction.do"> > > > > > > > > > > > > > > > > <% for(int i=0; i<5; i++){ %> > > > > <% String name1 = "friendName[" + i+ "]";%> > > > > > > > > > > > > > > > > > > > > <% } %> > > > > > > > >
My > > Friend's > > > > List
> > maxlength="64" > > > > size="50"/>
My Friend <%= i %> > > maxlength="6" > > > > size="6" />
> > > value="Submit" />
> > > >
> > > > > > > > and struts config > > > > > > > > > > > > > type="com.principal.group.acquire.proposal.ui.benefits.myTestForm"> > > > > > > > type="java.util.List" /> > > > > > > > type="java.lang.String" /> > > > > > > > > > > > > > > > > so the data populated by the open action is > > shown > === message truncated === __________________________________ Do you Yahoo!? Win a $20,000 Career Makeover at Yahoo! HotJobs http://hotjobs.sweepstakes.yahoo.com/careermakeover --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@struts.apache.org For additional commands, e-mail: user-help@struts.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@struts.apache.org For additional commands, e-mail: user-help@struts.apache.org