Thanks very much, this was the problem. I didn't realize that (if I
understand the problem correctly) setting name="item" in the html:text tag
would tell it to put the result in a form-bean called "item" instead of
the correct one which was "items".
Brady
> I really think the inconsistent usage of item/items is your problem
> here. Try changing the c:forEach var="item" to be var="items" and then
> change your html:text name="item" to have name="items".
>
> The name for the html:text needs to generate the form-property from your
> form bean definition for this to work correctly.
>
> Matt
>
>
>
>
> [EMAIL PROTECTED] wrote:
>
>> I caught the DynaValidatorActionForm/DynaValidatorForm problem too after
>> I
>> sent out the email and corrected it but it didn't help.
>>
>> Here are a few lines of my JSP (which should explain the item/items
>> question):
>>
>> <html:form method="post" action="saveEdit">
>> <c:forEach var="item" items="${Items.map.items}">
>> <html:text name="item" indexed="true" property="quantity" />
>> <html:text name="item" indexed="true" property="price" />
>> </c:forEach>
>> </html:form>
>>
>> and here's the resulting html:
>>
>> <form name="InventoryItems" method="post" action="/saveEdit">
>> <input type="text" name="item[0].quantity" value="10">
>> <input type="text" name="item[0].price" value="45.0">
>> <input type="text" name="item[1].quantity" value="">
>> <input type="text" name="item[1].price" value="225.0">
>> </form>
>>
>> BTW: I tried updating my struts libs to 1.2.4 but that didn't help. I
>> also put a String into the Items formbean and a corresponding textfield
>> on
>> the page and that data passes through just fine. It's only the item[x]
>> changes that fail.
>>
>> Thanks,
>> Brady
>>
>>
>>>I see 2 things wrong right now - first is that you are using a
>>>DynaValidatorActionForm in your form-bean definition, but a
>>>DynaValidatorForm to cast the form in your loader and action code. This
>>>is not the cause of your problem I think, just something to watch out
>>> for.
>>>
>>>The second is that I'm not entirely sure how those form variables got
>>>generated - based on what I see in your form-bean definition and in your
>>> java code, the form property you are loading with this data is called
>>>"items" - the form is apparently generating input tags with "item[x].ID"
>>>(etc.) as the name, instead of "items[x].ID" (etc.) as the name. This
>>>would most explain why when you read the form data it is just reading
>>>the default instead of what you changed it to in the form.
>>>
>>>If neither of these helped, I would say that we also need to see a
>>>cut/paste of the JSP for the form, and a cut/paste of what gets
>>>generated to the brower.
>>>
>>>Matt
>>>
>>>
>>>
>>>
>>>
>>>
>>>[EMAIL PROTECTED] wrote:
>>>
>>>
>>>>Thanks for the reply. Here are the relevant sections of LoadAction and
>>>>PersistAction:
>>>>
>>>>LoadAction:
>>>>public ActionForward execute(
>>>> ActionMapping mapping,
>>>> ActionForm form,
>>>> HttpServletRequest request,
>>>> HttpServletResponse response)
>>>> throws Exception {
>>>>
>>>> DynaValidatorForm passForm = (DynaValidatorForm)form;
>>>>
>>>> SimpleItem[] itemsArray = new SimpleItem[2];
>>>>
>>>> itemsArray[0] = new SimpleItem();
>>>> itemsArray[0].setQuantity("10");
>>>> itemsArray[0].setPrice("45.0");
>>>>
>>>> itemsArray[1] = new SimpleItem();
>>>> itemsArray[1].setQuantity("");
>>>> itemsArray[1].setPrice("225.0");
>>>>
>>>> passForm.set( "items", itemsArray );
>>>>
>>>> return mapping.findForward( "success" );
>>>>}
>>>>
>>>>
>>>>PersistAction:
>>>>public ActionForward execute(
>>>> ActionMapping mapping,
>>>> ActionForm form,
>>>> HttpServletRequest request,
>>>> HttpServletResponse response)
>>>> throws Exception {
>>>>
>>>> DynaValidatorForm passForm = (DynaValidatorForm) form;
>>>>
>>>> SimpleItem[] itemArray = (SimpleItem[])passForm.get("items");
>>>>
>>>> return mapping.findForward(forward);
>>>>}
>>>>
>>>>
>>>>
>>>>>>I'm working from the examples here:
>>>>>>http://www.developer.com/java/ejb/article.php/3321521
>>>>>>
>>>>>>I have an array of values that are sent to a page for editing. The
>>>>>>page
>>>>>>is coming up ok with the correct text box values as seen below
>>>>>>(item[0].xxx, etc). But when the form is submitted the changes don't
>>>>>>show up in PersistEditAction. The form contains the original data
>>>>>> just
>>>>>>as it was before the forward from LoadEditAction.
>>>>>>
>>>>>>Thanks for any help,
>>>>>>Brady
>>>>>>
>>>>>><input type="text" name="item[0].quantity" value="">
>>>>>><input type="text" name="item[0].price" value="785.0">
>>>>>>
>>>>>><input type="text" name="item[1].quantity" value="">
>>>>>><input type="text" name="item[1].price" value="225.0">
>>>>>>
>>>>>>
>>>>>><form-bean
>>>>>> name="Items"
>>>>>> type="org.apache.struts.validator.DynaValidatorActionForm">
>>>>>> <form-property name="items"
>>>>>> type="com.litriusgroup.cart.hibernate.SimpleItem[]" />
>>>>>></form-bean>
>>>>>>
>>>>>><action path="/Edit"
>>>>>> type="com.stuff.struts.LoadEditAction"
>>>>>> name="Items"
>>>>>> scope="session"
>>>>>> validate="false">
>>>>>> <forward name="success" path="/admin/edit.jsp" />
>>>>>></action>
>>>>>><action path="/saveEdit"
>>>>>> type="com.stuff.struts.PersistEditAction"
>>>>>> name="Items"
>>>>>> scope="session"
>>>>>> validate="false">
>>>>>> <forward name="success" path="/admin/edit.jsp" />
>>>>>> <forward name="error" path="/admin/edit.jsp" />
>>>>>></action>
>>>>>>
>>>>>Is it possible you can post the relevant parts of LoadEditAction and
>>>>>PersistEditAction? Without those I don't think anybody will be able to
>>>>>help.
>>>>>
>>>>>Matt
>
>
> ---------------------------------------------------------------------
> 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]