struts-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From craig...@locus.apache.org
Subject cvs commit: jakarta-struts/src/example/org/apache/struts/example ApplicationMapping.java EditRegistrationAction.java EditSubscriptionAction.java LogonAction.java LogonForm.java RegistrationForm.java SaveRegistrationAction.java SaveSubscriptionAction.java SubscriptionForm.java
Date Thu, 12 Oct 2000 21:53:49 GMT
craigmcc    00/10/12 14:53:48

  Modified:    src/example/org/apache/struts/example
                        ApplicationMapping.java EditRegistrationAction.java
                        EditSubscriptionAction.java LogonAction.java
                        LogonForm.java RegistrationForm.java
                        SaveRegistrationAction.java
                        SaveSubscriptionAction.java SubscriptionForm.java
  Log:
  Update the struts-example application sources to the recent changes
  in the org.apache.struts.action package.
  
  Revision  Changes    Path
  1.3       +6 -6      jakarta-struts/src/example/org/apache/struts/example/ApplicationMapping.java
  
  Index: ApplicationMapping.java
  ===================================================================
  RCS file: /home/cvs/jakarta-struts/src/example/org/apache/struts/example/ApplicationMapping.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ApplicationMapping.java	2000/08/01 20:03:22	1.2
  +++ ApplicationMapping.java	2000/10/12 21:53:39	1.3
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-struts/src/example/org/apache/struts/example/ApplicationMapping.java,v
1.2 2000/08/01 20:03:22 craigmcc Exp $
  - * $Revision: 1.2 $
  - * $Date: 2000/08/01 20:03:22 $
  + * $Header: /home/cvs/jakarta-struts/src/example/org/apache/struts/example/ApplicationMapping.java,v
1.3 2000/10/12 21:53:39 craigmcc Exp $
  + * $Revision: 1.3 $
  + * $Date: 2000/10/12 21:53:39 $
    *
    * ====================================================================
    *
  @@ -63,7 +63,7 @@
   package org.apache.struts.example;
   
   
  -import org.apache.struts.action.ActionMappingBase;
  +import org.apache.struts.action.ActionMapping;
   
   
   /**
  @@ -79,10 +79,10 @@
    * </ul>
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.2 $ $Date: 2000/08/01 20:03:22 $
  + * @version $Revision: 1.3 $ $Date: 2000/10/12 21:53:39 $
    */
   
  -public final class ApplicationMapping extends ActionMappingBase {
  +public final class ApplicationMapping extends ActionMapping {
   
   
       // --------------------------------------------------- Instance Variables
  
  
  
  1.7       +5 -5      jakarta-struts/src/example/org/apache/struts/example/EditRegistrationAction.java
  
  Index: EditRegistrationAction.java
  ===================================================================
  RCS file: /home/cvs/jakarta-struts/src/example/org/apache/struts/example/EditRegistrationAction.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- EditRegistrationAction.java	2000/09/23 22:53:52	1.6
  +++ EditRegistrationAction.java	2000/10/12 21:53:40	1.7
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-struts/src/example/org/apache/struts/example/EditRegistrationAction.java,v
1.6 2000/09/23 22:53:52 craigmcc Exp $
  - * $Revision: 1.6 $
  - * $Date: 2000/09/23 22:53:52 $
  + * $Header: /home/cvs/jakarta-struts/src/example/org/apache/struts/example/EditRegistrationAction.java,v
1.7 2000/10/12 21:53:40 craigmcc Exp $
  + * $Revision: 1.7 $
  + * $Date: 2000/10/12 21:53:40 $
    *
    * ====================================================================
    *
  @@ -85,7 +85,7 @@
    * User (if any).
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.6 $ $Date: 2000/09/23 22:53:52 $
  + * @version $Revision: 1.7 $ $Date: 2000/10/12 21:53:40 $
    */
   
   public final class EditRegistrationAction extends Action {
  @@ -138,7 +138,7 @@
   	// Populate the user registration form
   	if (form == null) {
   	    form = new RegistrationForm();
  -	    session.setAttribute(mapping.getFormAttribute(), form);
  +	    session.setAttribute(mapping.getAttribute(), form);
   	}
   	RegistrationForm regform = (RegistrationForm) form;
   	regform.setAction(action);
  
  
  
  1.7       +5 -5      jakarta-struts/src/example/org/apache/struts/example/EditSubscriptionAction.java
  
  Index: EditSubscriptionAction.java
  ===================================================================
  RCS file: /home/cvs/jakarta-struts/src/example/org/apache/struts/example/EditSubscriptionAction.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- EditSubscriptionAction.java	2000/09/23 22:53:53	1.6
  +++ EditSubscriptionAction.java	2000/10/12 21:53:41	1.7
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-struts/src/example/org/apache/struts/example/EditSubscriptionAction.java,v
1.6 2000/09/23 22:53:53 craigmcc Exp $
  - * $Revision: 1.6 $
  - * $Date: 2000/09/23 22:53:53 $
  + * $Header: /home/cvs/jakarta-struts/src/example/org/apache/struts/example/EditSubscriptionAction.java,v
1.7 2000/10/12 21:53:41 craigmcc Exp $
  + * $Revision: 1.7 $
  + * $Date: 2000/10/12 21:53:41 $
    *
    * ====================================================================
    *
  @@ -84,7 +84,7 @@
    * <code>SubscriptionForm</code> from the currently specified subscription.
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.6 $ $Date: 2000/09/23 22:53:53 $
  + * @version $Revision: 1.7 $ $Date: 2000/10/12 21:53:41 $
    */
   
   public final class EditSubscriptionAction extends Action {
  @@ -151,7 +151,7 @@
   	// Populate the subscription form
   	if (form == null) {
   	    form = new SubscriptionForm();
  -	    session.setAttribute(mapping.getFormAttribute(), form);
  +	    session.setAttribute(mapping.getAttribute(), form);
   	}
   	SubscriptionForm subform = (SubscriptionForm) form;
   	subform.setAction(action);
  
  
  
  1.8       +13 -10    jakarta-struts/src/example/org/apache/struts/example/LogonAction.java
  
  Index: LogonAction.java
  ===================================================================
  RCS file: /home/cvs/jakarta-struts/src/example/org/apache/struts/example/LogonAction.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- LogonAction.java	2000/09/23 22:53:53	1.7
  +++ LogonAction.java	2000/10/12 21:53:41	1.8
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-struts/src/example/org/apache/struts/example/LogonAction.java,v
1.7 2000/09/23 22:53:53 craigmcc Exp $
  - * $Revision: 1.7 $
  - * $Date: 2000/09/23 22:53:53 $
  + * $Header: /home/cvs/jakarta-struts/src/example/org/apache/struts/example/LogonAction.java,v
1.8 2000/10/12 21:53:41 craigmcc Exp $
  + * $Revision: 1.8 $
  + * $Date: 2000/10/12 21:53:41 $
    *
    * ====================================================================
    *
  @@ -72,11 +72,12 @@
   import javax.servlet.http.HttpSession;
   import javax.servlet.http.HttpServletResponse;
   import org.apache.struts.action.Action;
  +import org.apache.struts.action.ActionError;
  +import org.apache.struts.action.ActionErrors;
   import org.apache.struts.action.ActionForm;
   import org.apache.struts.action.ActionForward;
   import org.apache.struts.action.ActionMapping;
   import org.apache.struts.action.ActionServlet;
  -import org.apache.struts.util.ErrorMessages;
   import org.apache.struts.util.MessageResources;
   
   
  @@ -84,7 +85,7 @@
    * Implementation of <strong>Action</strong> that validates a user logon.
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.7 $ $Date: 2000/09/23 22:53:53 $
  + * @version $Revision: 1.8 $ $Date: 2000/10/12 21:53:41 $
    */
   
   public final class LogonAction extends Action {
  @@ -120,25 +121,27 @@
   	User user = null;
   
   	// Validate the request parameters specified by the user
  -	ErrorMessages errors = new ErrorMessages();
  +	ActionErrors errors = new ActionErrors();
   	String username = ((LogonForm) form).getUsername();
   	String password = ((LogonForm) form).getPassword();
   	Hashtable database = (Hashtable)
   	  servlet.getServletContext().getAttribute(Constants.DATABASE_KEY);
   	if (database == null)
  -	    errors.addError("error.database.missing");
  +            errors.add(ActionErrors.GLOBAL_ERROR,
  +                       new ActionError("error.database.missing"));
   	else {
   	    user = (User) database.get(username);
   	    if ((user != null) && !user.getPassword().equals(password))
   		user = null;
   	    if (user == null)
  -		errors.addError("error.password.mismatch");
  +                errors.add(ActionErrors.GLOBAL_ERROR,
  +                           new ActionError("error.password.mismatch"));
   	}
   
   	// Report any errors we have discovered back to the original form
  -	if (errors.getSize() > 0) {
  +	if (!errors.empty()) {
   	    saveErrors(request, errors);
  -	    return (new ActionForward(mapping.getInputForm()));
  +	    return (new ActionForward(mapping.getInput()));
   	}
   
   	// Save our logged-in user in the session
  
  
  
  1.4       +27 -23    jakarta-struts/src/example/org/apache/struts/example/LogonForm.java
  
  Index: LogonForm.java
  ===================================================================
  RCS file: /home/cvs/jakarta-struts/src/example/org/apache/struts/example/LogonForm.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- LogonForm.java	2000/08/01 20:03:24	1.3
  +++ LogonForm.java	2000/10/12 21:53:41	1.4
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-struts/src/example/org/apache/struts/example/LogonForm.java,v
1.3 2000/08/01 20:03:24 craigmcc Exp $
  - * $Revision: 1.3 $
  - * $Date: 2000/08/01 20:03:24 $
  + * $Header: /home/cvs/jakarta-struts/src/example/org/apache/struts/example/LogonForm.java,v
1.4 2000/10/12 21:53:41 craigmcc Exp $
  + * $Revision: 1.4 $
  + * $Date: 2000/10/12 21:53:41 $
    *
    * ====================================================================
    *
  @@ -63,8 +63,11 @@
   package org.apache.struts.example;
   
   
  -import java.util.Vector;
  -import org.apache.struts.action.ValidatingActionForm;
  +import javax.servlet.http.HttpServletRequest;
  +import org.apache.struts.action.ActionError;
  +import org.apache.struts.action.ActionErrors;
  +import org.apache.struts.action.ActionForm;
  +import org.apache.struts.action.ActionMapping;
   
   
   /**
  @@ -76,10 +79,10 @@
    * </ul>
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.3 $ $Date: 2000/08/01 20:03:24 $
  + * @version $Revision: 1.4 $ $Date: 2000/10/12 21:53:41 $
    */
   
  -public final class LogonForm implements ValidatingActionForm {
  +public final class LogonForm extends ActionForm {
   
   
       // --------------------------------------------------- Instance Variables
  @@ -154,24 +157,25 @@
   
   
       /**
  -     * Validate the properties of this form bean, and return an array of
  -     * message keys for any errors we encounter.
  +     * Validate the properties that have been set from this HTTP request,
  +     * and return an <code>ActionErrors</code> object that encapsulates any
  +     * validation errors that have been found.  If no errors are found, return
  +     * <code>null</code> or an <code>ActionErrors</code> object
with no
  +     * recorded error messages.
  +     *
  +     * @param mapping The ActionMapping used to select this instance
  +     * @param request The servlet request we are processing
        */
  -    public String[] validate() {
  +    public ActionErrors validate(ActionMapping mapping,
  +                                 HttpServletRequest request) {
  +
  +        ActionErrors errors = new ActionErrors();
  +        if ((username == null) || (username.length() < 1))
  +            errors.add("username", new ActionError("error.username.required"));
  +        if ((password == null) || (password.length() < 1))
  +            errors.add("password", new ActionError("error.password.required"));
   
  -        Vector errors = new Vector();
  -	if ((username == null) || (username.length() < 1))
  -	    errors.addElement("error.username.required");
  -	if ((password == null) || (password.length() < 1))
  -	    errors.addElement("error.password.required");
  -
  -        String[] results = null;
  -        if (errors.size() > 0) {
  -            results = new String[errors.size()];
  -            for (int i = 0; i < results.length; i++)
  -                results[i] = (String) errors.elementAt(i);
  -        }
  -        return results;
  +        return errors;
   
       }
   
  
  
  
  1.7       +40 -23    jakarta-struts/src/example/org/apache/struts/example/RegistrationForm.java
  
  Index: RegistrationForm.java
  ===================================================================
  RCS file: /home/cvs/jakarta-struts/src/example/org/apache/struts/example/RegistrationForm.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- RegistrationForm.java	2000/09/24 03:59:49	1.6
  +++ RegistrationForm.java	2000/10/12 21:53:42	1.7
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-struts/src/example/org/apache/struts/example/RegistrationForm.java,v
1.6 2000/09/24 03:59:49 craigmcc Exp $
  - * $Revision: 1.6 $
  - * $Date: 2000/09/24 03:59:49 $
  + * $Header: /home/cvs/jakarta-struts/src/example/org/apache/struts/example/RegistrationForm.java,v
1.7 2000/10/12 21:53:42 craigmcc Exp $
  + * $Revision: 1.7 $
  + * $Date: 2000/10/12 21:53:42 $
    *
    * ====================================================================
    *
  @@ -63,9 +63,11 @@
   package org.apache.struts.example;
   
   
  -import java.util.Vector;
  -import org.apache.struts.action.ValidatingActionForm;
  -import org.apache.struts.util.ErrorMessages;
  +import javax.servlet.http.HttpServletRequest;
  +import org.apache.struts.action.ActionError;
  +import org.apache.struts.action.ActionErrors;
  +import org.apache.struts.action.ActionForm;
  +import org.apache.struts.action.ActionMapping;
   
   
   /**
  @@ -88,10 +90,10 @@
    * </ul>
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.6 $ $Date: 2000/09/24 03:59:49 $
  + * @version $Revision: 1.7 $ $Date: 2000/10/12 21:53:42 $
    */
   
  -public final class RegistrationForm implements ValidatingActionForm  {
  +public final class RegistrationForm extends ActionForm  {
   
   
       // --------------------------------------------------- Instance Variables
  @@ -322,32 +324,47 @@
   
   
       /**
  -     * Validate the properties of this form bean, and return an array of
  -     * message keys for any errors we encounter.
  +     * Validate the properties that have been set from this HTTP request,
  +     * and return an <code>ActionErrors</code> object that encapsulates any
  +     * validation errors that have been found.  If no errors are found, return
  +     * <code>null</code> or an <code>ActionErrors</code> object
with no
  +     * recorded error messages.
  +     *
  +     * @param mapping The ActionMapping used to select this instance
  +     * @param request The servlet request we are processing
        */
  -    public String[] validate() {
  +    public ActionErrors validate(ActionMapping mapping,
  +                                 HttpServletRequest request) {
   
  -	ErrorMessages errors = new ErrorMessages();
  -	if ((username == null) || (username.length() < 1))
  -	    errors.addError("error.username.required");
  -	if (!password.equals(password2))
  -	    errors.addError("error.password.match");
  -	if ((fromAddress == null) || (fromAddress.length() < 1))
  -	    errors.addError("error.fromAddress.required");
  -	else {
  +        ActionErrors errors = new ActionErrors();
  +        if ((username == null) || (username.length() < 1))
  +            errors.add("username",
  +                       new ActionError("error.username.required"));
  +        if (!password.equals(password2))
  +            errors.add("password2",
  +                       new ActionError("error.password.match"));
  +        if ((fromAddress == null) || (fromAddress.length() < 1))
  +            errors.add("fromAddress",
  +                       new ActionError("error.fromAddress.required"));
  +        else {
   	    int atSign = fromAddress.indexOf("@");
   	    if ((atSign < 1) || (atSign >= (fromAddress.length() - 1)))
  -		errors.addError("error.fromAddress.format");
  +		errors.add("fromAddress",
  +                           new ActionError("error.fromAddress.format",
  +                                           fromAddress));
   	}
   	if ((fullName == null) || (fullName.length() < 1))
  -	    errors.addError("error.fullName.required");
  +            errors.add("fullName",
  +                       new ActionError("error.fullName.required"));
   	if ((replyToAddress != null) && (replyToAddress.length() > 0)) {
   	    int atSign = replyToAddress.indexOf("@");
   	    if ((atSign < 1) || (atSign >= (replyToAddress.length() - 1)))
  -		errors.addError("error.replyToAddress.format");
  +                errors.add("replyToAddress",
  +                           new ActionError("error.replyToAddress.format",
  +                                           replyToAddress));
   	}
   
  -	return (errors.getErrors());
  +        return errors;
   
       }
   
  
  
  
  1.9       +20 -15    jakarta-struts/src/example/org/apache/struts/example/SaveRegistrationAction.java
  
  Index: SaveRegistrationAction.java
  ===================================================================
  RCS file: /home/cvs/jakarta-struts/src/example/org/apache/struts/example/SaveRegistrationAction.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- SaveRegistrationAction.java	2000/09/23 22:53:53	1.8
  +++ SaveRegistrationAction.java	2000/10/12 21:53:42	1.9
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-struts/src/example/org/apache/struts/example/SaveRegistrationAction.java,v
1.8 2000/09/23 22:53:53 craigmcc Exp $
  - * $Revision: 1.8 $
  - * $Date: 2000/09/23 22:53:53 $
  + * $Header: /home/cvs/jakarta-struts/src/example/org/apache/struts/example/SaveRegistrationAction.java,v
1.9 2000/10/12 21:53:42 craigmcc Exp $
  + * $Revision: 1.9 $
  + * $Date: 2000/10/12 21:53:42 $
    *
    * ====================================================================
    *
  @@ -72,11 +72,12 @@
   import javax.servlet.http.HttpSession;
   import javax.servlet.http.HttpServletResponse;
   import org.apache.struts.action.Action;
  +import org.apache.struts.action.ActionError;
  +import org.apache.struts.action.ActionErrors;
   import org.apache.struts.action.ActionForm;
   import org.apache.struts.action.ActionForward;
   import org.apache.struts.action.ActionMapping;
   import org.apache.struts.action.ActionServlet;
  -import org.apache.struts.util.ErrorMessages;
   import org.apache.struts.util.MessageResources;
   
   
  @@ -86,7 +87,7 @@
    * registration is created, the user is also implicitly logged on.
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.8 $ $Date: 2000/09/23 22:53:53 $
  + * @version $Revision: 1.9 $ $Date: 2000/10/12 21:53:42 $
    */
   
   public final class SaveRegistrationAction extends Action {
  @@ -137,8 +138,8 @@
   	    if (servlet.getDebug() >= 1)
   	        servlet.log("SaveRegistrationAction:  Transaction '" + action +
   	                    "' was cancelled");
  -	    if (mapping.getFormAttribute() != null)
  -	        session.removeAttribute(mapping.getFormAttribute());
  +	    if (mapping.getAttribute() != null)
  +	        session.removeAttribute(mapping.getAttribute());
   	    session.removeAttribute(Constants.SUBSCRIPTION_KEY);
   	    return (mapping.findForward("success"));
   	}
  @@ -147,24 +148,28 @@
   
   	// Validate the request parameters specified by the user
   	String value = null;
  -	ErrorMessages errors = new ErrorMessages();
  +	ActionErrors errors = new ActionErrors();
   	value = regform.getUsername();
   	if (("Create".equals(action)) &&
   	    (database.get(value) != null))
  -	    errors.addError("error.username.unique");
  +            errors.add("username",
  +                       new ActionError("error.username.unique",
  +                                       regform.getUsername()));
   	if ("Create".equals(action)) {
   	    value = regform.getPassword();
   	    if ((value == null) || (value.length() <1))
  -		errors.addError("error.password.required");
  +                errors.add("password",
  +                           new ActionError("error.password.required"));
   	    value = regform.getPassword2();
   	    if ((value == null) || (value.length() < 1))
  -		errors.addError("error.password2.required");
  +                errors.add("password2",
  +                           new ActionError("error.password2.required"));
   	}
   
   	// Report any errors we have discovered back to the original form
  -	if (errors.getSize() > 0) {
  +	if (!errors.empty()) {
   	    saveErrors(request, errors);
  -	    return (new ActionForward(mapping.getInputForm()));
  +	    return (new ActionForward(mapping.getInput()));
   	}
   
   	// Update the user's persistent profile information
  @@ -196,8 +201,8 @@
   	}
   
   	// Remove any obsolete session objects
  -	if (mapping.getFormAttribute() != null)
  -	    session.removeAttribute(mapping.getFormAttribute());
  +	if (mapping.getAttribute() != null)
  +	    session.removeAttribute(mapping.getAttribute());
   
   	// Forward control to the specified success URI
   	return (mapping.findForward("success"));
  
  
  
  1.9       +12 -11    jakarta-struts/src/example/org/apache/struts/example/SaveSubscriptionAction.java
  
  Index: SaveSubscriptionAction.java
  ===================================================================
  RCS file: /home/cvs/jakarta-struts/src/example/org/apache/struts/example/SaveSubscriptionAction.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- SaveSubscriptionAction.java	2000/09/23 22:53:53	1.8
  +++ SaveSubscriptionAction.java	2000/10/12 21:53:42	1.9
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-struts/src/example/org/apache/struts/example/SaveSubscriptionAction.java,v
1.8 2000/09/23 22:53:53 craigmcc Exp $
  - * $Revision: 1.8 $
  - * $Date: 2000/09/23 22:53:53 $
  + * $Header: /home/cvs/jakarta-struts/src/example/org/apache/struts/example/SaveSubscriptionAction.java,v
1.9 2000/10/12 21:53:42 craigmcc Exp $
  + * $Revision: 1.9 $
  + * $Date: 2000/10/12 21:53:42 $
    *
    * ====================================================================
    *
  @@ -72,11 +72,12 @@
   import javax.servlet.http.HttpSession;
   import javax.servlet.http.HttpServletResponse;
   import org.apache.struts.action.Action;
  +import org.apache.struts.action.ActionError;
  +import org.apache.struts.action.ActionErrors;
   import org.apache.struts.action.ActionForm;
   import org.apache.struts.action.ActionForward;
   import org.apache.struts.action.ActionMapping;
   import org.apache.struts.action.ActionServlet;
  -import org.apache.struts.util.ErrorMessages;
   import org.apache.struts.util.MessageResources;
   
   
  @@ -85,7 +86,7 @@
    * updates the mail subscription entered by the user.
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.8 $ $Date: 2000/09/23 22:53:53 $
  + * @version $Revision: 1.9 $ $Date: 2000/10/12 21:53:42 $
    */
   
   public final class SaveSubscriptionAction extends Action {
  @@ -146,8 +147,8 @@
   	    if (servlet.getDebug() >= 1)
   	        servlet.log("SaveSubscriptionAction:  Transaction '" + action +
   	                    "' was cancelled");
  -	    if (mapping.getFormAttribute() != null)
  -	        session.removeAttribute(mapping.getFormAttribute());
  +	    if (mapping.getAttribute() != null)
  +	        session.removeAttribute(mapping.getAttribute());
   	    session.removeAttribute(Constants.SUBSCRIPTION_KEY);
   	    return (mapping.findForward("success"));
   	}
  @@ -160,8 +161,8 @@
   	                    user.getUsername() + "'");
   	    subscription.setHost(null);
   	    subscription.setUser(null);
  -	    if (mapping.getFormAttribute() != null)
  -	        session.removeAttribute(mapping.getFormAttribute());
  +	    if (mapping.getAttribute() != null)
  +	        session.removeAttribute(mapping.getAttribute());
   	    session.removeAttribute(Constants.SUBSCRIPTION_KEY);
   	    return (mapping.findForward("success"));
   	}
  @@ -179,8 +180,8 @@
   	    subscription.setType(subform.getType());
   
   	// Remove any obsolete session objects
  -	if (mapping.getFormAttribute() != null)
  -	    session.removeAttribute(mapping.getFormAttribute());
  +	if (mapping.getAttribute() != null)
  +	    session.removeAttribute(mapping.getAttribute());
   	session.removeAttribute(Constants.SUBSCRIPTION_KEY);
   
   	// Forward control to the specified success URI
  
  
  
  1.7       +33 -18    jakarta-struts/src/example/org/apache/struts/example/SubscriptionForm.java
  
  Index: SubscriptionForm.java
  ===================================================================
  RCS file: /home/cvs/jakarta-struts/src/example/org/apache/struts/example/SubscriptionForm.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- SubscriptionForm.java	2000/08/01 20:03:25	1.6
  +++ SubscriptionForm.java	2000/10/12 21:53:43	1.7
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-struts/src/example/org/apache/struts/example/SubscriptionForm.java,v
1.6 2000/08/01 20:03:25 craigmcc Exp $
  - * $Revision: 1.6 $
  - * $Date: 2000/08/01 20:03:25 $
  + * $Header: /home/cvs/jakarta-struts/src/example/org/apache/struts/example/SubscriptionForm.java,v
1.7 2000/10/12 21:53:43 craigmcc Exp $
  + * $Revision: 1.7 $
  + * $Date: 2000/10/12 21:53:43 $
    *
    * ====================================================================
    *
  @@ -63,9 +63,11 @@
   package org.apache.struts.example;
   
   
  -import java.util.Vector;
  -import org.apache.struts.action.ValidatingActionForm;
  -import org.apache.struts.util.ErrorMessages;
  +import javax.servlet.http.HttpServletRequest;
  +import org.apache.struts.action.ActionError;
  +import org.apache.struts.action.ActionErrors;
  +import org.apache.struts.action.ActionForm;
  +import org.apache.struts.action.ActionMapping;
   
   
   /**
  @@ -82,10 +84,10 @@
    * </ul>
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.6 $ $Date: 2000/08/01 20:03:25 $
  + * @version $Revision: 1.7 $ $Date: 2000/10/12 21:53:43 $
    */
   
  -public final class SubscriptionForm implements ValidatingActionForm  {
  +public final class SubscriptionForm extends ActionForm  {
   
   
       // --------------------------------------------------- Instance Variables
  @@ -253,24 +255,37 @@
   
   
       /**
  -     * Validate the properties of this form bean, and return an array of
  -     * message keys for any errors we encounter.
  +     * Validate the properties that have been set from this HTTP request,
  +     * and return an <code>ActionErrors</code> object that encapsulates any
  +     * validation errors that have been found.  If no errors are found, return
  +     * <code>null</code> or an <code>ActionErrors</code> object
with no
  +     * recorded error messages.
  +     *
  +     * @param mapping The ActionMapping used to select this instance
  +     * @param request The servlet request we are processing
        */
  -    public String[] validate() {
  +    public ActionErrors validate(ActionMapping mapping,
  +                                 HttpServletRequest request) {
  +
  +        ActionErrors errors = new ActionErrors();
   
  -	ErrorMessages errors = new ErrorMessages();
   	if ((host == null) || (host.length() < 1))
  -	    errors.addError("error.host.required");
  +            errors.add("host",
  +                       new ActionError("error.host.required"));
   	if ((username == null) || (username.length() < 1))
  -	    errors.addError("error.username.required");
  +            errors.add("username",
  +                       new ActionError("error.username.required"));
   	if ((password == null) || (password.length() < 1))
  -	    errors.addError("error.password.required");
  +            errors.add("password",
  +                       new ActionError("error.password.required"));
   	if ((type == null) || (type.length() < 1))
  -	    errors.addError("error.type.required");
  +            errors.add("type",
  +                       new ActionError("error.type.required"));
   	else if (!"imap".equals(type) && !"pop3".equals(type))
  -	    errors.addError("error.type.invalid");
  +            errors.add("type",
  +                       new ActionError("error.type.invalid", type));
   
  -	return (errors.getErrors());
  +	return (errors);
   
       }
   
  
  
  

Mime
View raw message