On Fri, 22 Mar 2002, Matt Raible wrote:
> Date: Fri, 22 Mar 2002 08:40:43 -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?
>
> 1. Since a key has to be specified in struts-config.xml - what is the
> point of the super(key, value) in ExpiredPasswordException?
>
The "key" attribute of an <exception> is the message key for the
ActionError message that gets created. This is the text that will
normally get sent back to the user. In ExpiredPasswordException, the
key is used to localize the text of the exception's getMessage() string,
which is probably what's going to get logged if the exception handler logs
things.
Note that it's not required to have your application exceptions extend
org.apache.struts.util.AppException -- they can be anything you want. I
imagine a lot of people will want to let the exception handling mechanisms
deal with java.sql.SQLException problems, for example.
> 2. I added the code from <%-- Error Messages --%> to
> changePassword.jsp, and the key="expired.password" showed up on the
> page. However, when I added {0} to the key, no substitution occurred.
>
> Is this a bug? I can enter into bugzilla if so.
>
It's not clear exactly what you tried to do -- please file this as a bug
(with a completed example) if it's still a problem.
> Thanks,
>
> Matt
Craig
>
> > -----Original Message-----
> > From: Matt Raible [mailto:[EMAIL PROTECTED]]
> > Sent: Wednesday, March 20, 2002 8:21 PM
> > To: 'Struts Developers List'
> > 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. In struts-config.xml there is
> >
> > <exception key="expired.password"
> > type="org.apache.struts.webapp.example.ExpiredPasswordExceptio
> > n" 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:[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]>