Get rid of the 'name' and 'type' attributes from the <html:form>.  The reasons?

* they are deprecated.  See
  http://jakarta.apache.org/struts/userGuide/struts-html.html#form
* they are not necessary
* in your case the action mapping is referring to the form-bean
  by the name 'myForm' and the <html:form>'s 'name' attribute is
  indicating that a form named 'updateOrderForm' be used.  These
  will result in two instances of the same class.  Not what you
  want

Hope that helps

Sri

-----Original Message-----
From: MarwanSalam <[EMAIL PROTECTED]> [mailto:[EMAIL PROTECTED]] 
Sent: Thursday, February 20, 2003 3:58 PM
To: [EMAIL PROTECTED]
Subject: Re: Where are my ActionForm's changes?


Hi Sri,

You got it right.

This is the code from my Action class that checks for the changes and 
forwards the request to the same page again(I tried to forward to a 
view-only page(showorderdetails.jsp) for testing purposes and the 
changes still were not reflected).


UpdateOrdersAction.java
-------------------------
UpdateOrderForm updateOrderForm = (UpdateOrderForm) form;

if ("updateOrder".equalsIgnoreCase(action))
{
 List parametersList = updateOrderForm.getParameterList();

 int size = parametersList.size();

 for (int i = 0; i < size; i++)
 {
  OrderDetailModel model = ((UpdateOrderForm) form).getOrderDetail(i);
  logger.debug("Form model is: " + model);
 }

 Iterator iter = parametersList.iterator();
 if (logger.isDebugEnabled())
 {
  while (iter.hasNext())
  {
  OrderDetailModel orderDetail = (OrderDetailModel)iter.next();
  logger.debug(orderDetail.toString());
  }
 }

 logger.debug(" Forwarding to 'edit' page");
 NDC.pop();
 return (mapping.findForward("edit")); 
// this will take you back to the same page
}



Here is an excerpt from "updateorder.jsp":
-----------------------------------------
<html:form action="updateOrder" name="updateOrderForm" 
type="mypackage.UpdateOrderForm" scope="session">
<html:hidden property="action" value="updateOrder" /> <logic:iterate id="parameter" 
name="updateOrderForm" 
property="parameterList">
<tr>
<td><bean:write name="parameter" property="orderLineNumber" /></td> <td><bean:write 
name="parameter" property="itemName" /></td> <td><bean:write name="parameter" 
property="quantityOrdered" /></td> <td><html:text name="parameter" 
property="quantityCancelled" 
indexed="true" size="3" maxlength="3"/></td>
<td><html:text name="parameter" property="status" indexed="true" 
size="3" maxlength="3"/></td>
</tr>
</logic:iterate>
<html:submit/>
</html:form>

I appreciate your help.

Marwan


--- In [EMAIL PROTECTED], "Sri Sankaran" <[EMAIL PROTECTED]> 
wrote:
> What I have gleaned so far, is
> 
> * the user is viewing JSP-1
> * the user updates the data and submits (invoking the action
>   mapping you have shown (path=/updateOrder)
> 
> Questions:
> * Are you detecting the updated data value(s) in your action?
> * Where is the user being directed?
>   If showorderdetails.jsp or updateorder.jsp what is mapping for 
>   those pages?
> * Where are you noticing problems?
> 
> Remember that if you go to new page and it uses a form-bean of the
same class but referred to by a different name, a new instance will 
be used.
> 
> Sri
> 
> -----Original Message-----
> From: MarwanSalam <[EMAIL PROTECTED]> [mailto:marwansalam@y...]
> Sent: Thursday, February 20, 2003 1:55 PM
> To: [EMAIL PROTECTED]
> Subject: Re: Where are my ActionForm's changes?
> 
> 
> Thanks Sri for the quick reply.
> 
> The first of two assumptions you mentioned below are not true but I
> am not sure about the third one: "forwarding to an action that is 
re- initializing the form".
> 
> My ActionForm.reset() is as follows:
> 
> public void reset(ActionMapping mapping, HttpServletRequest
request) {
>   action = null;
> }
> 
> And here is my action-mapping:
> 
> <action path="/updateOrder"
>         type="MyAction"
>         name="myForm"
>         scope="session"
>         validate="false"
>         input="/updateorder.jsp">
>   <forward name="update"             path="/showorderdetails.jsp"/>
>   <forward name="edit"             path="/updateorder.jsp"/>
> </action>
> 
> 
> The reset method does not have any code that initializes the form
> parameters so I don't know why this is happening.
> 
> Marwan
> 
> 
> --- In [EMAIL PROTECTED], "Sri Sankaran" <[EMAIL PROTECTED]>
> wrote:
> > I'm not sure I understand completely.  Are you returning to the
> same page after the form is submitted?  What are you doing in the
> reset() and Action?
> > 
> > That notwithstanding, here are some possibilities:
> > 
> > * The text fields are not within a form
> > * You are re-directing to the page and not forwarding
> > * You are forwarding (or redirecting) to an action that is
> >   re-initializing the form.
> > 
> > Will need to see the necessary action mappings too.
> > 
> > Sri
> > 
> > > -----Original Message-----
> > > From: MarwanSalam <[EMAIL PROTECTED]> [mailto:marwansalam@y...]
> > > Sent: Thursday, February 20, 2003 1:09 PM
> > > To: [EMAIL PROTECTED]
> > > Subject: Where are my ActionForm's changes?
> > > 
> > > 
> > > Hi,
> > > 
> > > I am using the <login:iterate> tag to display a collection of
> > > objects. The objects have attributes that some can
> > > be edited by the user. After the user changes some values and 
> submits 
> > > back to the Action class, the values that were changed in the 
JSP
> are 
> > > not reflected in the form. I know that because I tried to 
iterate
> > > through the collection and displayed the values retained from 
> both 
> > > the ActionForm.reset() and from the Action class. No changes are
> > > retained; only the original values. I am using Struts 1.1-b3.
> > > 
> > > Here is my ActionForm:
> > > 
> > > private List parameterList = new ArrayList();
> > > public List getParameterList()
> > > {
> > >   return parameterList;
> > > }
> > > 
> > > public void setParameterList(List parameterList)
> > > {
> > >   this.parameterList = parameterList;
> > > }
> > > 
> > > public MyObject getMyObject(int index)
> > > {
> > >   return (MyObject) parameterList.get(index);
> > > }
> > > 
> > > What's wrong?
> > > 
> > > Marwan
> > > 
> > > 
> > > ----------------------------------------------------------------
--
> ---
> > > 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]
> 
> 
> --------------------------------------------------------------------
-
> 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]


---------------------------------------------------------------------
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]

Reply via email to