Return-Path: Delivered-To: apmail-struts-user-archive@www.apache.org Received: (qmail 78352 invoked from network); 29 Apr 2004 21:45:03 -0000 Received: from daedalus.apache.org (HELO mail.apache.org) (208.185.179.12) by minotaur-2.apache.org with SMTP; 29 Apr 2004 21:45:03 -0000 Received: (qmail 30109 invoked by uid 500); 29 Apr 2004 21:44:30 -0000 Delivered-To: apmail-struts-user-archive@struts.apache.org Received: (qmail 30078 invoked by uid 500); 29 Apr 2004 21:44:30 -0000 Mailing-List: contact user-help@struts.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Struts Users Mailing List" Reply-To: "Struts Users Mailing List" Delivered-To: mailing list user@struts.apache.org Received: (qmail 30061 invoked from network); 29 Apr 2004 21:44:30 -0000 Received: from unknown (HELO us131.principal.com) (206.195.193.10) by daedalus.apache.org with SMTP; 29 Apr 2004 21:44:30 -0000 Received: from us131.principal.com ([127.0.0.1]) by us131.principal.com (Switch-3.1.3/Switch-3.1.0) with ESMTP id i3TLiarN004653 for ; Thu, 29 Apr 2004 16:44:36 -0500 (CDT) Received: from PFGDSMBHS001.principalusa.corp.principal.com (pfgdsmbhs001.principalusa.corp.principal.com [162.131.46.184]) by us131.principal.com (Switch-3.1.3/Switch-3.1.0) with ESMTP id i3TLi4uA004361 for ; Thu, 29 Apr 2004 16:44:34 -0500 (CDT) Received: from pfgdsmmbx004.principalusa.corp.principal.com ([162.131.23.128]) by PFGDSMBHS001.principalusa.corp.principal.com with Microsoft SMTPSVC(5.0.2195.6713); Thu, 29 Apr 2004 16:44:15 -0500 x-mimeole: Produced By Microsoft Exchange V6.0.6375.0 content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Subject: RE: ArrayList and DynaActionForm--need help very badly Date: Thu, 29 Apr 2004 16:44:15 -0500 Message-ID: <9145180F5F33C243B7BB8C377FF8DA9A02F901B8@pfgdsmmbx004.principalusa.corp.principal.com> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: ArrayList and DynaActionForm--need help very badly Thread-Index: AcQuK5+BPtsuM/tBT2y1QaZTFILy4wABnQ0g From: "Mathew, Manoj" To: "Struts Users Mailing List" X-OriginalArrivalTime: 29 Apr 2004 21:44:15.0586 (UTC) FILETIME=[1E110C20:01C42E33] X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N 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 > >=20 > > I still get the same and agian nameList =3D null > >=20 > > [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. > >=20 > > List mm =3D new ArrayList(); > > List nameList =3D ListUtils.lazyList(mm, new > > Factory() { > > public Object create() { > > return new String(); > > } > > }); > > set("friendName", nameList); > >=20 > > Regards, > >=20 > > Richard > >=20 > >=20 > > 1) define the the=20 > > --- "Mathew, Manoj" > > wrote: > > > Richard=20 > > > 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) > > >=20 > > > struts config > > >=20 > > > > > type=3D"org.apache.struts.action.DynaActionForm"> > > > > > > > > type=3D"org.apache.commons.collections.ListUtils.LazyList" > > > /> > > >=20 > > > Thank-you, > > > Manoj Mathew > > > GIS-Systems > > > (515-362-0539) > > >=20 > > >=20 > > > -----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 > > >=20 > > >=20 > > > 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 =3D new ArrayList(); > > > > List nameList =3D ListUtils.lazyList(mm, new > > > > Factory() { > > > > public Object create() { > > > > return "fakeName"; > > > > } > > > > }); > > > > set("friendName", nameList); > > >=20 > > > 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. > > >=20 > > > 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. > > >=20 > > >=20 > > > Regards, > > >=20 > > > Richard > > > --- "Mathew, Manoj" > > > wrote: > > > > Let me explain in detail > > > >=20 > > > > I have a open action which just populate the > > > > list..and forwarded to my jsp > > > >=20 > > > > public class MyTestOpenAction extends Action { > > > > public ActionForward execute(ActionMapping > > > mapping, > > > > ActionForm frm, > > > > javax.servlet.http.HttpServletRequest request, > > > > javax.servlet.http.HttpServletResponse response) > > > > throws Exception { > > > >=20 > > > > myTestForm form =3D (myTestForm) frm; > > > > form.set("myName","Manoj Mathew"); > > > > form.set("friendName", getMyList()); > > > > return mapping.findForward("success"); > > > > } > > > >=20 > > > > private List getMyList() { > > > >=20 > > > > List myList =3D new ArrayList(); > > > > myList.add(0, "Jimmy"); > > > > myList.add(1, "Tom"); > > > > myList.add(2, "Jack"); > > > > myList.add(3, "Jack2"); > > > > myList.add(4, "Jack3"); > > > > return myList; > > > > } > > > >=20 > > > > } > > > >=20 > > > > and my jsp looks like this > > > >=20 > > > >=20 > > > > > > > action=3D"mytestjsppostaction.do"> > > > > > > > > > > > > > > > > <% for(int i=3D0; i<5; i++){ %> > > > > <% String name1 =3D "friendName[" + i+ "]";%> > > > > > > > > > > > > > > > > > > > > <% } %> > > > > > > > >
My > > Friend's > > > > List
> > maxlength=3D"64" > > > > size=3D"50"/>
My Friend <%=3D i %>" > > > maxlength=3D"6" > > > > size=3D"6" />
> > > value=3D"Submit" />
> > > >
> > > >=20 > > > > and struts config=20 > > > > > > > > > > > > > type=3D"com.principal.group.acquire.proposal.ui.benefits.myTestForm"> > > > > > > > type=3D"java.util.List" /> > > > > > > > type=3D"java.lang.String" /> > > > > > > > >=20 > > > >=20 > > > > so the data populated by the open action is > > shown >=20 =3D=3D=3D message truncated =3D=3D=3D =09 =09 __________________________________ Do you Yahoo!? Win a $20,000 Career Makeover at Yahoo! HotJobs =20 http://hotjobs.sweepstakes.yahoo.com/careermakeover=20 --------------------------------------------------------------------- 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