I apologize in advance if this comes through twice. Our email server was having issues this morning, so I'm resending it in case it didn't make it out the first time. Thanks! I am attempting to do something similar to what has been posted here in the current Struts application that I'm working on. I'm using a DynaValidatorForm in request scope, iterating through a dynamically generated ArrayList that I've put into the DynaValidatorForm, and then attempting to pass it through request scope using indexed properties. The page displays perfectly, but when I try to submit it, I get the following error: [Servlet Error]-[BeanUtils.populate]: java.lang.NullPointerException: No indexed value for 'inventoryList[0]' at org.apache.struts.action.DynaActionForm.get(DynaActionForm.java:293) at org.apache.commons.beanutils.PropertyUtils.getIndexedProperty(PropertyUtils.java:474).... Here are some snippets of code: >From the ActionClass that populates the .JSP: ArrayList itemRanges = itemCDTO.getItemRanges(); //returns an ArrayList of ItemRange beans form.set("inventoryList", itemRanges); >From struts-config.xml: <form-bean name="inventoryModifyForm" type="org.apache.struts.validator.DynaValidatorForm"> <form-property name="page" type="java.lang.Integer" /> <form-property name="submit" type="java.lang.String" /> <form-property name="rangeStart" type="java.lang.String" /> <form-property name="rangeEnd" type="java.lang.String" /> <form-property name="inventoryList" type="java.util.ArrayList" /> <form-property name="description" type="java.lang.String" /> </form-bean> <action path="/inventoryModify" type="gov.dor.fastr.action.inventory.InventoryModifyAction" name="inventoryModifyForm" scope="request" input="inventory.modify" validate="false"> <forward name="cancelled" path="inventory.cancelled" /> <forward name="page2" path="inventory.modify2" /> </action> >From the JSP: <logic:iterate id="inventoryList" name="inventoryModifyForm" property="inventoryList" > <tr> <td> <html:text indexed="true" name="inventoryList" property="startNumber" /> <html:text indexed="true" name="inventoryList" property="endNumber" /> </td> </tr> </logic:iterate> An interesting thing I noticed when I change the code in the JSP like this: <logic:iterate id="iList" name="inventoryModifyForm" property="inventoryList" > <tr> <td> <html:text indexed="true" name="iList" property="startNumber" /> <html:text indexed="true" name="iList" property="endNumber" /> </td> </tr> </logic:iterate> ....then I don't get the error. But of course, when I do an (ArrayList) form.get("inventoryList"), it returns an empty List to the Action class. I can, however, bypass the DynaValidatorForm and directly query the HttpServletRequest object and pull the individual components by doing a request.getParameter("iList[0].startNumber"), which is extremely clunky. I'm sure I must be missing something stupid. If anyone can shed some light, it would be greatly appreciated. Thanks so much! Brent -----Original Message----- From: Yee, Richard K,,DMDCWEST [<mailto:[EMAIL PROTECTED]>] Sent: Friday, November 21, 2003 4:23 PM To: 'Struts Users Mailing List' Subject: RE: dynamically sized form (mostly solved)
Matt, You actually only need the form in the request. You don't need the property of the form at all in your JSP. In my JSP I use <html:form action="/indexTestSubmitAction"> <logic:iterate id="testBean" name="dynaIndexTestForm" property="tests" indexId="ctr" > <html:text name="testBean" property="id" /><br> <html:text name="testBean" property="amount" /><br> <html:text name="testBean" property="name"/> </logic:iterate> <html:submit value="Update"/> </html:form> In struts-config.xml I have this <form-beans> <form-bean name="dynaIndexTestForm" type="org.apache.struts.action.DynaActionForm"> <form-property name="tests" type="mil.osd.dmdc.deers.tests.beans.TestBean[]"/> </form-bean> </form-beans> <action-mappings> <action path="/indexTestSubmitAction" type="mil.osd.dmdc.deers.apps.test.actions.TestAction" name="dynaIndexTestForm" scope="request" input="/loginSucceeded.jsp"> <forward name="success" path="/succeeded.jsp" redirect="false"/> </action> </action-mappings> -Richard -----Original Message----- From: Matt Bathje [<mailto:[EMAIL PROTECTED]>] Sent: Friday, November 21, 2003 2:17 PM To: Struts Users Mailing List Subject: Re: dynamically sized form (mostly solved) > I found out that using new DynaActionForm()inside of the > PreLoaderAction.execute() doesn't work. It gives a null pointer > exception when you try and call the set() method. > > You need to do this instead: > > FormBeanConfig cfg = mapping.getModuleConfig() > .findFormBeanConfig("dynaIndexTestForm"); > DynaActionForm myForm; > Richard - this was the last piece of the puzzle for me, now it works without having to supply the name="form" on the preloader action...sweet. Mark - I have had it working both ways now, in session and request. If you want to do it in request you have to have 2 request objects in your preload. The first is the form itself, and the second is the property for the form (which is what you actually loop through in your jsp) I will probably use the request scope myself just because I try to stay out of session as much as possible. Thanks, Matt Bathje --------------------------------------------------------------------- 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] ____________________________________________________________ This message sent using iMail from I-Land Internet Services. http://www.iland.net --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]