Yes, the validate method is going with the ActionMessages as well. However, the Validator Plug-in is something that should be looked at. It is a little more object based in nature so you do not end up repeating the same validations on multiple forms. It returns errors in the same mannor as the validate method. As for error handlers, I will typically define error handlers for exceptions that are global / generic in nature. These could be something like a business logic based exception or unexpected errors (Session missing, NullPointer, etc.).

Naturally, their is nothing wrong with defining a errorHandler, but like you, I like to customize messages if I can. The more detail you can provide to an end user that is specific to what they did, the less phone calls you will recieve.

Inactive hide details for "Gaet" <[EMAIL PROTECTED]>"Gaet" <[EMAIL PROTECTED]>


          "Gaet" <[EMAIL PROTECTED]>

          06/30/2005 08:29 AM

          Please respond to
          "Struts Users Mailing List" <user@struts.apache.org>

To

"Struts Users Mailing List" <user@struts.apache.org>

cc


Subject

Re: Exception - General Question

Thanks for replying!

And what baout the validate() method in struts form? Is it still return ActionErrors or ActionMessages?

What about the exception Handler? what is the best pratice between catching in each action class or in the hander?

Thanks for help!

 ----- Original Message -----
 From: [EMAIL PROTECTED]
 To: Struts Users Mailing List
 Cc: Mailing List Struts
 Sent: Thursday, June 30, 2005 2:16 PM
 Subject: Re: Exception - General Question


 In 1.2.7 you simply change the ActionErrors to ActionMessages. you still save the errors with the saveErrors method and it works the same in the tags.

 "Gaet" <[EMAIL PROTECTED]>


               "Gaet" <[EMAIL PROTECTED]>
               06/30/2005 04:54 AM Please respond to
                     "Struts Users Mailing List" <user@struts.apache.org>

     

             To
             "Mailing List Struts" <user@struts.apache.org>


             cc
           


             Subject
             Exception - General Question
             
     

 Hi everybody,

 Up to now, I was handling my exceptions in my Action class as follow :

 ----------------------------------------------------------------------------
 ----------------
    ActionErrors errors = new ActionErrors();
    try{
    ......
    ......

    } catch (Exception e) {
    //Put print stack trace in System.err so it is logged
    e.printStackTrace(System.err);
    //
    errors.add(ActionErrors.GLOBAL_ERROR, new
 ActionMessage("errors.keyDescribingError : "+e.getMessage()));
    saveErrors(request, errors);
    // Forward control to the appropriate error page
    forward = mapping.findForward("erreur");
    }
 ----------------------------------------------------------------------------
 ----------------


 However ActionErrors is now deprecated so I'm wondering if using
 ActionMessages instead is well appropriate.????

 I have seen that a common use is to define an ExceptionHandler....seems to
 be nice as we just handke the errors in one place but :
    - It seems that using ExceptionHandler we lost the finest degree of the
 exception and we have not a personnalized message for the exception thrown.
       Of course, we could do a catch in the Action class and throw the
 exception with the personalized messaged but then I have another question :
            - Does ExceptionHandler slower than catching the exception in
 each Action class?

 Finally, What is the best practice to handle exceptions in struts?

 Thanks in advance for your help








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




Reply via email to