You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by Matt Raible <ma...@raibledesigns.com> on 2002/03/21 01:18:45 UTC
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
Also, will Tiles be adapted as a Plug In?
I upgraded my app using 1.1 beta 1 with Tiles & Validator this afternoon
- took me about 10 minutes. Mostly validator changes. Nice work!
Matt
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
RE: Declarative Exception Handling - Any Documentation?
Posted by Matt Raible <ma...@raibledesigns.com>.
Sorry, STFA eh? I found an example in struts-example - any others
examples?
Thanks,
Matt
> -----Original Message-----
> From: Matt Raible [mailto:matt@raibledesigns.com]
> Sent: Wednesday, March 20, 2002 5:19 PM
> To: struts-dev@jakarta.apache.org
> 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
Also, will Tiles be adapted as a Plug In?
I upgraded my app using 1.1 beta 1 with Tiles & Validator this afternoon
- took me about 10 minutes. Mostly validator changes. Nice work!
Matt
--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
RE: Declarative Exception Handling - Any Documentation?
Posted by "Craig R. McClanahan" <cr...@apache.org>.
See intermixed.
On Wed, 20 Mar 2002, Matt Raible wrote:
> Date: Wed, 20 Mar 2002 20:21:20 -0700
> From: Matt Raible <ma...@raibledesigns.com>
> Reply-To: Struts Developers List <st...@jakarta.apache.org>,
> matt@raibledesigns.com
> To: 'Struts Developers List' <st...@jakarta.apache.org>
> Subject: RE: Declarative Exception Handling - Any Documentation?
>
> After investigating the PasswordExpiredException, I'm a little confused.
> This class uses the following code:
>
> <code>
> public ExpiredPasswordException(String username) {
> super("error.password.expired", username);
> }
> </code>
>
> But there is no key "error.password.expired" in
> ApplicationResources.properties.
This was an oversight that has just been corrected. This key is used to
localize the exception message (since in this particular case we are
extending org.apache.struts.util.AppException for precisely that
capability). Whether or not the exception is logged is up to the
exception handler you map to handle it.
> In struts-config.xml there is
>
> <exception key="expired.password"
> type="org.apache.struts.webapp.example.ExpiredPasswordException"
> path="/changePassword.jsp"/>
>
> And I found an "expired.password" key, but this is never used. How are
> each designed to be used - simply for logging? There are no messages
> that show up in the log for either of these.
>
The default exception handler (org.apache.struts.action.ExceptionHandler
uses this key to create an ActionError that is stored in request or
session scope, as identified by the "scope" attribute. Override exception
handlers can do whatever they want.
> Here's how I would expect these to be used.
>
> 1. If no key is specified in struts-config, then the key
> "error.password.expired" would be used.
At the moment, the "key" attribute is marked required in the DTD, so this
won't happen.
> 2. This message would be attainable with the following JSP code:
>
> <%-- Error Messages --%>
> <logic:messagesPresent>
> <html:messages id="error">
> <bean:write name="error"/><br/>
> </html:messages>
> </logic:messagesPresent>
>
This will work if you're using the default exception handler. If you
override, things, it depends on what your override class does.
> Is this correct? Also, is it possible to have a separate .properties
> file for Exception messages?
>
> This stuff is great, as well as the rest of Struts - awesome to work
> with this stuff. You all do an awesome job - makes my life a lot
> easier.
>
> Matt
>
Craig
>
> > -----Original Message-----
> > From: Craig R. McClanahan [mailto:craigmcc@apache.org]
> > Sent: Wednesday, March 20, 2002 5:55 PM
> > To: Struts Developers List; matt@raibledesigns.com
> > Subject: Re: Declarative Exception Handling - Any Documentation?
> >
> >
> >
> >
> > On Wed, 20 Mar 2002, Matt Raible wrote:
> >
> > > Date: Wed, 20 Mar 2002 17:18:45 -0700
> > > From: Matt Raible <ma...@raibledesigns.com>
> > > Reply-To: Struts Developers List <st...@jakarta.apache.org>,
> > > matt@raibledesigns.com
> > > To: struts-dev@jakarta.apache.org
> > > 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.htm
> > > l
> > >
> >
> > 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: <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
>
>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
RE: Declarative Exception Handling - Any Documentation?
Posted by Matt Raible <ma...@raibledesigns.com>.
After investigating the PasswordExpiredException, I'm a little confused.
This class uses the following code:
<code>
public ExpiredPasswordException(String username) {
super("error.password.expired", username);
}
</code>
But there is no key "error.password.expired" in
ApplicationResources.properties. In struts-config.xml there is
<exception key="expired.password"
type="org.apache.struts.webapp.example.ExpiredPasswordException"
path="/changePassword.jsp"/>
And I found an "expired.password" key, but this is never used. How are
each designed to be used - simply for logging? There are no messages
that show up in the log for either of these.
Here's how I would expect these to be used.
1. If no key is specified in struts-config, then the key
"error.password.expired" would be used.
2. This message would be attainable with the following JSP code:
<%-- Error Messages --%>
<logic:messagesPresent>
<html:messages id="error">
<bean:write name="error"/><br/>
</html:messages>
</logic:messagesPresent>
Is this correct? Also, is it possible to have a separate .properties
file for Exception messages?
This stuff is great, as well as the rest of Struts - awesome to work
with this stuff. You all do an awesome job - makes my life a lot
easier.
Matt
> -----Original Message-----
> From: Craig R. McClanahan [mailto:craigmcc@apache.org]
> Sent: Wednesday, March 20, 2002 5:55 PM
> To: Struts Developers List; matt@raibledesigns.com
> Subject: Re: Declarative Exception Handling - Any Documentation?
>
>
>
>
> On Wed, 20 Mar 2002, Matt Raible wrote:
>
> > Date: Wed, 20 Mar 2002 17:18:45 -0700
> > From: Matt Raible <ma...@raibledesigns.com>
> > Reply-To: Struts Developers List <st...@jakarta.apache.org>,
> > matt@raibledesigns.com
> > To: struts-dev@jakarta.apache.org
> > 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.htm
> > l
> >
>
> 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: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Declarative Exception Handling - Any Documentation?
Posted by "Craig R. McClanahan" <cr...@apache.org>.
On Wed, 20 Mar 2002, Matt Raible wrote:
> Date: Wed, 20 Mar 2002 17:18:45 -0700
> From: Matt Raible <ma...@raibledesigns.com>
> Reply-To: Struts Developers List <st...@jakarta.apache.org>,
> matt@raibledesigns.com
> To: struts-dev@jakarta.apache.org
> 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: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>