The method I use to is to remove & recreate the form bean. I wouldn't use
the reset method - this is not for resetting the form bean in the way you
suggest - it is called for you by Struts. Here is the method I use to do
this:

    public ActionForm recreateFormBean(ActionMapping mapping, ActionForm
form, HttpServletRequest request,
                                       HttpServletResponse response) throws
ServletException {

        String attr = mapping.getAttribute();
        String scope = mapping.getScope();

        if (scope.equals("session")) {
            request.getSession().removeAttribute(attr);
        } else {
            request.removeAttribute(attr);
        }
        ActionForm f = RequestUtils.createActionForm(request, mapping,
mapping.getModuleConfig(), servlet);

        if (scope.equals("session")) {
            request.getSession().setAttribute(attr, f);
        } else {
            request.setAttribute(attr, f);
        }
        //call reset, as struts would do befor the use of any form bean
        f.reset(mapping, request);

        //populate the form bean with any request parameters - from
RequestProcessor.processPopulate
        if (mapping.getMultipartClass() != null) {
            request.setAttribute(Globals.MULTIPART_KEY,
                                 mapping.getMultipartClass());
        }
        RequestUtils.populate(f, mapping.getPrefix(), mapping.getSuffix(),
                              request);

        // Set the cancellation request attribute if appropriate
        if
((request.getParameter(org.apache.struts.taglib.html.Constants.CANCEL_PROPER
TY) != null) ||
        
(request.getParameter(org.apache.struts.taglib.html.Constants.CANCEL_PROPERT
Y_X) != null)) {
            request.setAttribute(Globals.CANCEL_KEY, Boolean.TRUE);
        }

        return f;

    }


Paul

> -----Original Message-----
> From: Sebastian Ho [mailto:[EMAIL PROTECTED]
> Sent: Thursday, August 26, 2004 9:07 AM
> To: Struts Users Mailing List
> Subject: RE: how to reset form
> 
> 
> 1. I need to use session for this one.
> 
> 2. The textfield in the JSP didn't load the value from the 
> bean. It is a
> normal textfield.
> 
> How do I reset in my case?
> 
> 
> On Thu, 2004-08-26 at 16:07, Yves Sy wrote:
> > I mean your "actionform" is stored in session scope by default :)
> > 
> > Regards,
> > -Yves- 
> > 
> > > -----Original Message-----
> > > From: Yves Sy [mailto:[EMAIL PROTECTED]
> > > Sent: Thursday, August 26, 2004 4:02 PM
> > > To: 'Struts Users Mailing List'
> > > Subject: RE: how to reset form
> > > 
> > > 
> > > This is happening because your session is stored in 
> session scope by
> > > default.
> > > 
> > > You should explicitly specify scope="request" in your 
> actionmapping.
> > > 
> > > Regards,
> > > -Yves-
> > > 
> > > > -----Original Message-----
> > > > From: Sebastian Ho [mailto:[EMAIL PROTECTED]
> > > > Sent: Thursday, August 26, 2004 3:33 PM
> > > > To: Struts Users Mailing List
> > > > Subject: how to reset form
> > > >
> > > > hi
> > > >
> > > > A user submits a form and the action class forward it 
> back to the
> > same
> > > > JSP. The values entered previously is still there. How 
> do I clear it
> > > > before action returns actionforward?
> > > >
> > > > Thanks
> > > >
> > > > Sebastian Ho
> > > >
> > > >
> > > >
> > 
> ---------------------------------------------------------------------
> > > > 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]
> 


**********************************************************************
Axios Email Confidentiality Footer
Privileged/Confidential Information may be contained in this message. If you are not 
the addressee indicated in this message (or responsible for delivery of the message to 
such person), you may not copy or deliver this message to anyone. In such case, you 
should destroy this message, and notify us immediately. If you or your employer does 
not consent to Internet email messages of this kind, please advise us immediately. 
Opinions, conclusions and other information expressed in this message are not given or 
endorsed by my Company or employer unless otherwise indicated by an authorised 
representative independent of this message.
WARNING:
While Axios Systems Ltd takes steps to prevent computer viruses from being transmitted 
via electronic mail attachments we cannot guarantee that attachments do not contain 
computer virus code.  You are therefore strongly advised to undertake anti virus 
checks prior to accessing the attachment to this electronic mail.  Axios Systems Ltd 
grants no warranties regarding performance use or quality of any attachment and 
undertakes no liability for loss or damage howsoever caused.
**********************************************************************


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to