See intermixed.

On Wed, 20 Mar 2002, Matt Raible wrote:

> Date: Wed, 20 Mar 2002 20:21:20 -0700
> From: Matt Raible <[EMAIL PROTECTED]>
> Reply-To: Struts Developers List <[EMAIL PROTECTED]>,
>      [EMAIL PROTECTED]
> To: 'Struts Developers List' <[EMAIL PROTECTED]>
> 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:[EMAIL PROTECTED]]
> > Sent: Wednesday, March 20, 2002 5:55 PM
> > To: Struts Developers List; [EMAIL PROTECTED]
> > 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 <[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->
> [EMAIL PROTECTED]/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:   <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
>
>


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

Reply via email to