Hi Martin & Durham

The mapping is definetly scoped as request, I checked it.

The form.reset before leaving the SaveAction does not work, because it
finds the bean somehow when arriving back to edit and that exactly the
problem. Only reset() in the EditAction it self works, but I really like
to know why the remove (or reset) in the calling Action does'nt work.
 
here's the relevant code from struts-config file:

<action path="/EditMsvItem"
type="org.nite.mashovweb.actions.EditMsvItemAction"
name="MsvItemForm"
scope="request"
validate="false"
parameter="action">
<forward name="success" path="/editMsvItem.jsp">
</forward>
<forward name="failure" path="/Error.jsp">
</forward>
</action>

<action path="/SaveMsvItem"
type="org.nite.mashovweb.actions.SaveMsvItemAction"
name="MsvItemForm"
scope="request"
input="/editMsvItem.jsp"
parameter="action">
<forward name="search" path="SearchMsvItem.do">
</forward>
<forward name="update_failure" path="/editMsvItem.jsp">
</forward>
<forward name="last_search_results"
path="SearchMsvItem.do?action=lastPage">
</forward>
<forward name="create_success" path="EditMsvItem.do?action=create">
</forward>
</action>

Also here's the create methods in SaveItemAction and in EditItemAction:

In saveItemAction:

public ActionForward create(
ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws Exception {

HttpSession session = request.getSession();
MsvItemForm subform = (MsvItemForm) form;
MsvItemTO newItem = new MsvItemTO();

if (isCancelled(request)) {
request.removeAttribute(mapping.getAttribute());
return (mapping.findForward("item_main_menu"));
}

try {
PropertyUtils.copyProperties(newItem, subform);
} catch (Throwable t) {
log.error("populate bean error", t);
throw new ServletException("populate bean error", t);
}

try {
MsvItemOperHome msvItemOperHome =
(MsvItemOperHome)ServiceLocator.getInstance().getRemoteHome("ejb/mashov/
MsvItemOperHome",MsvItemOperHome.class);
MsvItemOper msvItemOper = msvItemOperHome.create();
msvItemOper.createNewItem(newItem);
} catch (Exception e) {
log.error("insert error", e);
throw new ServletException("create item failed", e);
}

request.setAttribute("ErrorMessageKey","error.update.record.nochange");

request.removeAttribute(mapping.getAttribute());

session.removeAttribute(mapping.getAttribute()); //did not help
form.reset(mapping, request); //Duram - did not help

return (mapping.findForward("create_success"));

}

In EditItemAction:

        public ActionForward create(
        ActionMapping mapping,
        ActionForm form,
        HttpServletRequest request,
        HttpServletResponse response)
        throws Exception {
                            
        MsvItemForm subform = (MsvItemForm) form;
        //subform.reset(mapping, request); //needs checking
        subform.setAction("create");

        return (mapping.findForward("success"));

    }

It's a real strange thing!!


Thanks for trying

Rivka


-----Original Message-----
From: Martin Gainty [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, June 21, 2005 4:00 PM
To: Struts Users Mailing List
Subject: Re: problem with removing form bean

You should ensure your mapping scope is indeed 'request' e.g.
//Test for presence of attribute in Map
if (mapping.getAttribute() != null)
{
//Test that mapping is indeed scoped as request
if ("request".equals(mapping.getScope()))
{ //remove the attribute from the request
request.removeAttribute(mapping.getAttribute());
}
else
{ //acquire session
HttpSession session = request.getSession();
//remove the attribute from your request
session.removeAttribute(mapping.getAttribute());
}
}

I did not see the code for your edit function so I cannot comment on
that
HTH,
Martin-

----- Original Message ----- 
From: "Rivka Shisman" <[EMAIL PROTECTED]>
To: <user@struts.apache.org>
Sent: Tuesday, June 21, 2005 9:28 AM
Subject: problem with removing form bean


Hi all



I have a very annoying problem with a form bean:



I'm working with WSAD v6.0 (RAD v6.0) and struts v1.2.4



When creating a new Item I call EditItemAction (mehod create)

The ItemForm is created and the passed to editItem.jsp

>From there it arrives to SaveItemAction (method create)

and if the item was successfully saved it is returned with a success
message to EditItemAction (method create) - to enable the user to create
another item.



The problem is that when I get the input form the second time - it still
shows the data of the first Item that was created before, i.e. the form
bean is not removed.

In SaveItemAction i do :


request.setAttribute("MessageKey","update.record.success");

                        request.removeAttribute(mapping.getAttribute());

                        return (mapping.findForward("create_success"));



I know that the request that arrives to EditItemAction is the one I sent
from SaveItemAction because the attribute "MessageKey" arrives properly.

But for some reason, the ItemForm bean is not removed as I requested.



The scope in the struts-config is request and I also checked by printing
mapping.getScope() which was also request.





I really really need help with this one



Thanks

Rivka

************************************************************************
**************************
The contents of this email and any attachments are confidential.
They are intended for the named recipient(s) only.
If you have received this email in error please notify the system
manager or 
the
sender immediately and do not disclose the contents to anyone or make 
copies.

** eSafe scanned this email for viruses, vandals and malicious content.
**
************************************************************************
************************** 

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
**************************************************************************************************
The contents of this email and any attachments are confidential.
They are intended for the named recipient(s) only.
If you have received this email in error please notify the system manager or  
the 
sender immediately and do not disclose the contents to anyone or make copies.

** eSafe scanned this email for viruses, vandals and malicious content. **
**************************************************************************************************

Reply via email to