Little more input to the issue.It's working when i have this . So that mean that the lazyList trick is not working for some reason.see the commented codes.... public class myTestForm extends DynaActionForm {
public void reset(ActionMapping mapping, HttpServletRequest request) { // List nameList = ListUtils.lazyList(new ArrayList(), new Factory() { // public Object create() { // return new String(); // } // }); List nameList = getMyList(); set("friendName", nameList); } private List getMyList() { List mList = new ArrayList(); for (int i = 0; i < 5; i++) { mList.add("fakeName"); }return mList; } } Thank-you, Manoj Mathew GIS-Systems (515-362-0539) -----Original Message----- From: Hubert Rabago [mailto:[EMAIL PROTECTED] Sent: Thursday, April 29, 2004 5:03 PM To: Struts Users Mailing List Subject: RE: ArrayList and DynaActionForm--need help very badly Well, I'm back at nothing. Maybe someone else can spot what's happening. --- "Mathew, Manoj" <[EMAIL PROTECTED]> wrote: > 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. > > <action path="/myOpen" > type="com.principal.group.acquire.proposal.ui.benefits.MyTestOpenAction" > name="mytestform" scope="request"> > <forward name="success" path="/myTestJsp.jsp" /> > </action> > <action path="/mytestjsppostaction" > type="com.principal.group.acquire.proposal.ui.benefits.MyFormPost" > name="mytestform" scope="request"> > <forward name="success" path="/myTestJsp.jsp" /> > </action> > > 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" <[EMAIL PROTECTED]> > > > 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 > > > > > > > > <form-bean name="mytestform" > > > > type="org.apache.struts.action.DynaActionForm"> > > > > <form-property name="friendName" > > > > > > > > > type="org.apache.commons.collections.ListUtils.LazyList" > > > > /> > > > > > > > > Thank-you, > > > > Manoj Mathew > > > > GIS-Systems > > > > (515-362-0539) > > > > > > > > > > > > -----Original Message----- > > > > From: Richard Yee [mailto:[EMAIL PROTECTED] > > > > 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" <[EMAIL PROTECTED]> > > > > 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 > > > > > > > > > > > > > > > <html:form method="post" > > > > > action="mytestjsppostaction.do"> > > > > > <Table> > > > > > <TR><TD><font color="red" face="bold">My > > > Friend's > > > > > List</font></TD></TR> > > > > > <TR><TD><html:text property="myName" > > > > maxlength="64" > > > > > size="50"/></td></TR> > > > > > <% for(int i=0; i<5; i++){ %> > > > > > <% String name1 = "friendName[" + i+ "]";%> > > > > > <tr> > > > > > <td> My Friend <%= i %></td> > > > > > <td><html:text property="<%=name1%>" > > > > maxlength="6" > > > > > size="6" /></TD> > > > > > </tr> > > > > > <% } %> > > > > > <tr><td><html:submit property="censusSubmit" > > > > > value="Submit" /> </td></tr> > > > > > </table> > > > > > </html:form> > > > > > > > > > > and struts config > > > > > <form-bean name="mytestform" > > > > > > > > > > > > > > type="com.principal.group.acquire.proposal.ui.benefits.myTestForm"> > > > > > <form-property name="friendName" > > > > > type="java.util.List" /> > === message truncated === __________________________________ Do you Yahoo!? Win a $20,000 Career Makeover at Yahoo! HotJobs http://hotjobs.sweepstakes.yahoo.com/careermakeover --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]