You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Wendy Smoak <We...@asu.edu> on 2003/10/18 00:42:10 UTC

Deprecating ActionError/ActionErrors

I don't know if this work is still ongoing, but I notice that
ActionError and ActionErrors are deprecated, yet the validate method of
DynaValidatorForm still returns an ActionErrors object.

I looked at the validate method of DynaValidatorForm, and I'm confused.
It doesn't seem to do what it says it does.  AFAICT, this method
*always* returns the empty ActionErrors object that's created with:
        ActionErrors errors = new ActionErrors();

If errors ARE found, they're never put into that ActionErrors object,
they're stored in the protected ValidatorResults object.

 /**
     * 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 mapping used to select this instance.
     * @param request The servlet request we are processing.
     * @return <code>ActionErrors</code> object that encapsulates any
validation errors.
     */
    public ActionErrors validate(ActionMapping mapping,
HttpServletRequest request) {
        this.setPageFromDynaProperty();

        ServletContext application = getServlet().getServletContext();
        ActionErrors errors = new ActionErrors();

        Validator validator =
            Resources.initValidator(mapping.getAttribute(), this,
application, request, errors, page);

        try {
            validatorResults = validator.validate();
        } catch (ValidatorException e) {
            log.error(e.getMessage(), e);
        }

        return errors;
    }

Can someone who knows what's happening with ActionError/ActionErrors
please post a summary?

-- 
Wendy Smoak
Applications Systems Analyst, Sr.
Arizona State University, PA, IRM 


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: Deprecating ActionError/ActionErrors

Posted by Saul Q Yuan <yu...@dataanvil.com>.
----- Original Message -----
From: "Wendy Smoak" <We...@asu.edu>
To: <st...@jakarta.apache.org>
Sent: Friday, October 17, 2003 6:42 PM
Subject: Deprecating ActionError/ActionErrors


>
> I don't know if this work is still ongoing, but I notice that
> ActionError and ActionErrors are deprecated, yet the validate method of
> DynaValidatorForm still returns an ActionErrors object.
>
> I looked at the validate method of DynaValidatorForm, and I'm confused.
> It doesn't seem to do what it says it does.  AFAICT, this method
> *always* returns the empty ActionErrors object that's created with:
>         ActionErrors errors = new ActionErrors();

Well, this is not true.

According to the code, the errors object gets passed to the initValidator( )
method which returns a Validator object, and the validator object than calls
the validate() method. Since Java pass by reference, the error object could
be changed in the initValidator() method as well as in the subsequent
validate() method.

Saul


>
> If errors ARE found, they're never put into that ActionErrors object,
> they're stored in the protected ValidatorResults object.
>
>  /**
>      * 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 mapping used to select this instance.
>      * @param request The servlet request we are processing.
>      * @return <code>ActionErrors</code> object that encapsulates any
> validation errors.
>      */
>     public ActionErrors validate(ActionMapping mapping,
> HttpServletRequest request) {
>         this.setPageFromDynaProperty();
>
>         ServletContext application = getServlet().getServletContext();
>         ActionErrors errors = new ActionErrors();
>
>         Validator validator =
>             Resources.initValidator(mapping.getAttribute(), this,
> application, request, errors, page);
>
>         try {
>             validatorResults = validator.validate();
>         } catch (ValidatorException e) {
>             log.error(e.getMessage(), e);
>         }
>
>         return errors;
>     }
>
> Can someone who knows what's happening with ActionError/ActionErrors
> please post a summary?
>
> --
> Wendy Smoak
> Applications Systems Analyst, Sr.
> Arizona State University, PA, IRM
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: Deprecating ActionError/ActionErrors

Posted by David Graham <gr...@yahoo.com>.
--- Wendy Smoak <We...@asu.edu> wrote:
> 
> I don't know if this work is still ongoing, but I notice that
> ActionError and ActionErrors are deprecated, yet the validate method of
> DynaValidatorForm still returns an ActionErrors object.

Only ActionError is deprecated right now.  However, most of the references
to ActionErrors in Struts have been replaced with ActionMessages. 
ActionErrors is still around because it's in the ActionForm.validate()
method signature.  Use ActionMessage and ActionMessages wherever possible
for a Struts 1.2 app.  

Eventually, we'll use Commons Resources' Message and MessageList
interfaces.

David

> 
> I looked at the validate method of DynaValidatorForm, and I'm confused.
> It doesn't seem to do what it says it does.  AFAICT, this method
> *always* returns the empty ActionErrors object that's created with:
>         ActionErrors errors = new ActionErrors();
> 
> If errors ARE found, they're never put into that ActionErrors object,
> they're stored in the protected ValidatorResults object.
> 
>  /**
>      * 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 mapping used to select this instance.
>      * @param request The servlet request we are processing.
>      * @return <code>ActionErrors</code> object that encapsulates any
> validation errors.
>      */
>     public ActionErrors validate(ActionMapping mapping,
> HttpServletRequest request) {
>         this.setPageFromDynaProperty();
> 
>         ServletContext application = getServlet().getServletContext();
>         ActionErrors errors = new ActionErrors();
> 
>         Validator validator =
>             Resources.initValidator(mapping.getAttribute(), this,
> application, request, errors, page);
> 
>         try {
>             validatorResults = validator.validate();
>         } catch (ValidatorException e) {
>             log.error(e.getMessage(), e);
>         }
> 
>         return errors;
>     }
> 
> Can someone who knows what's happening with ActionError/ActionErrors
> please post a summary?
> 
> -- 
> Wendy Smoak
> Applications Systems Analyst, Sr.
> Arizona State University, PA, IRM 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
> 


__________________________________
Do you Yahoo!?
The New Yahoo! Shopping - with improved product search
http://shopping.yahoo.com

---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org