On Wed, 20 Mar 2002, Matt Raible wrote:

> Date: Wed, 20 Mar 2002 17:18:45 -0700
> From: Matt Raible <[EMAIL PROTECTED]>
> Reply-To: Struts Developers List <[EMAIL PROTECTED]>,
>      [EMAIL PROTECTED]
> To: [EMAIL PROTECTED]
> Subject: Declarative Exception Handling - Any Documentation?
>
> I *think* declarative exception handling has been added to the 1.1 beta
> 1 - correct me if I'm wrong.  If so, where can I find good documentation
> and examples on how to use it?  This is all I found:
>
> http://www.mail-archive.com/struts-dev@jakarta.apache.org/msg04150.html
>

It has.

To use it, you have to use the (new) execute() method in your Actions,
instead of perform() -- the signature includes "throws Exception" so that
you can throw any kind of exception you wish, and then have the controller
catch it.

To configure usage, use the <exception> elements inside a
<global-exceptions> section for global definitions, or inside an <action>
element for local overrides, analogous to the way forwards work.

A contrived use of this is in the Struts example webapp -- if you enter
the username "arithmetic", LogonAction will throw an ArithmeticException.
Likewise, if you enter the username "expired" it will throw an
ExpiredPasswordException (a business logic exception unique to this
webapp).  Only the business logic exception has a defined handler:

  <action path="/logon" ...>
    <exception key="expired.password"
              type="org.apache.struts.webapp.example.ExpiredPasswordException"
              path="/changePassword.jsp"/>
  </action>

> Also, will Tiles be adapted as a Plug In?
>

Makes sense to me ... but I'm not going to have a chance to do it.

> I upgraded my app using 1.1 beta 1 with Tiles & Validator this afternoon
> - took me about 10 minutes.  Mostly validator changes.  Nice work!
>

Cool!

> Matt
>

Craig


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

Reply via email to