Calling reset is a prelude to autopopulation. Unless the request is
being redirected along the way, this should just put the same values
back into the ActionForm. 

Reset must be called to ensure that the properties for some controls,
like checkboxes, are set correctly. The default reset does nothing. It
is really only needed for checkboxes.

Dan Tanner wrote:
> 
> >>I'm having the problem of losing form data when my
> >>action class returns
> >>errors.  The error displays properly, but I lose all
> >>the form data.
> >>
> > Maybe there is an issue with the reset method in your
> > ActionForm?  The validation error messages make sense?
> >  If they do then the data is being populated correctly
> > into your ActionForm from you form.
> 
> You're right...the form data is getting to the action, and for some
> reason the reset method is getting called when I don't think it should.
>    I have the form info in my action and it passes the form's
> validation, but if I add an error in the action and return a new
> ActionForward, the displayed page doesn't have the form info.
> 
> I'm a struts newbie, and odds are that I'm just missing something really
> lame, but I've been tearing my hair out trying to figure out what it is.
>     Is it that once a form gets past ActionForm.validate, the form data
> will no longer be returned?  I tried setting the form scope to both
> session and request, to no avail.
> 
> Thanks again for any help.
> 
> >>
> >>----------------------------------
> >>     <action
> >>         path="/user/add1"
> >>         type="com.usbank.crm.user.UserAction"
> >>         name="userForm"
> >>         scope="session"
> >>         validate="false"
> >>         input="/user/user1.jsp"
> >>         parameter="add">
> >>       <forward name="continue"
> >>path="/user/user1.jsp"/>
> >>       <forward name="cancel"
> >>path="/user/main.jsp"/>
> >>     </action>
> >>
> >>     <action
> >>         path="/user/edit1"
> >>         type="com.usbank.crm.user.UserAction"
> >>         name="userForm"
> >>         scope="session"
> >>         validate="false"
> >>         input="/user/user1.jsp"
> >>         parameter="select">
> >>       <forward name="continue"
> >>path="/user/user2.jsp"/>
> >>       <forward name="cancel"
> >>path="/user/main.jsp"/>
> >>     </action>
> >>
> >>     <action
> >>         path="/user/save1"
> >>         type="com.usbank.crm.user.UserAction"
> >>         name="userForm"
> >>         scope="session"
> >>         validate="true"
> >>         input="/user/user1.jsp"
> >>         parameter="continue">
> >>       <forward name="continue"
> >>path="/user/adduser2.jsp"/>
> >>       <forward name="cancel"
> >>path="/user/main.jsp"/>
> >>     </action>
> >>
> >>------------------------
> >>public class UserAction extends BaseAction {
> >>
> >>     protected ActionForward doAction(ActionMapping
> >>mapping,
> >>             ActionForm form, HttpServletRequest
> >>request,
> >>             HttpServletResponse response, String
> >>action)
> >>     {
> >>         UserForm userForm = (UserForm)form;
> >>
> >>         // add user action - this is the initial
> >>action when the user
> >>         // enters the page to create a new user
> >>         if ("add".equals(action)) {
> >>             System.err.println("\n\n\n in add
> >>action \n\n\n");
> >>
> >>             // populate the user type options
> >>             userForm.setUserType(2);
> >>
> >>             return (new
> >>ActionForward(mapping.getInput()));
> >>         }
> >>
> >>         // select - this is to edit an existing
> >>user
> >>         if ("select".equals(action)) {
> >>             System.err.println("\n\n\n in select
> >>action \n\n\n");
> >>
> >>             // get the userid
> >>
> >>             // populate the form
> >>
> >>             return (new
> >>ActionForward(mapping.getInput()));
> >>         }
> >>
> >>         // the continue is used for both adds and
> >>edits...it validates the
> >>         // data and continues on to the next page
> >>if successful.
> >>         if ("continue".equals(action)) {
> >>             System.err.println("\n\n\n in continue
> >>action \n\n\n");
> >>
> >>             // validate the username isn't already
> >>in use
> >>             boolean alreadyExists = true;  // will
> >>cause an ActionError
> >>
> >>             if (alreadyExists) {
> >>                 ActionErrors errors = new
> >>ActionErrors();
> >>
> >>
> >>errors.add(ActionErrors.GLOBAL_ERROR,
> >>                            new
> >>ActionError("error.username.already.exists"));
> >>
> >>                 saveErrors(request, errors);
> >>                 return
> >>(mapping.findForward("user1add"));
> >>             }
> >>
> >>             return
> >>(mapping.findForward("continue"));
> >>         }
> >>-------------------------------------
> >><html:form action="/user/save1" onsubmit="return
> >>validateUserForm(this);">
> >>
> >>
> >>--
> >>To unsubscribe, e-mail:
> >><mailto:[EMAIL PROTECTED]>
> >>For additional commands, e-mail:
> >><mailto:[EMAIL PROTECTED]>
> >>
> >
> >
> > __________________________________________________
> > Do You Yahoo!?
> > Send your FREE holiday greetings online!
> > http://greetings.yahoo.com
> >
> > --
> > To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
> > For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
> >
> >
> >
> 
> --
> To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

-- Ted Husted, Husted dot Com, Fairport NY USA.
-- Custom Software ~ Technical Services.
-- Tel +1 716 737-3463
-- http://www.husted.com/struts/

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

Reply via email to