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.

Looking at older posts, I've seen the same problem, but haven't seen a 
fix or workaround yet.  I've included the relevant code snippets.

Also, I like the added features of the latest validation.jar, but it 
forces me to use a newer version of struts than the 1.0 release because 
of its ActionMessage usage.  Are the latest nightly builds fairly safe, 
or would people recommend I stick with struts 1.0 for production until a 
new major release comes out?

Thanks in advance 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]>

Reply via email to