You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Schulte Marcus <ma...@bmw.ch> on 2005/05/04 09:33:02 UTC

Intercepting Exceptions in Tapestry Listeners

Hi, 
While I'm growing increasingly fond of Tapestry, there's one tiny advantage
to Struts-like Action-classes over listener-methods. Namely, being able to
easily provide Base-Actions taking, for example, care of (non-technical)
user exceptions by converting them into friendly messages. 
In Tapestry, a common base-class for all pages overriding
AbstractComponent's getListeners() method does the trick for me. I made it
return a sub-class of the standard ListenerMap, which, in turn wraps each of
the standard IActionListeners it returns into some custom IActionListener
taking care of the standard user exceptions like "ObjectNotFound",
"NoPermission", "OptimisticLockBroken" and the like by providing a nice
message to a page property (or a delegate-bean).
Still, the way you have to unwrap your exception from the
ApplicationRuntimeException is somewhat unsatisfactory. It's just too tight
coupling to framework-internals. 
Maybe, there should be some hook in the framework to plug-in custom
interceptors for listeners. At least, I'd find that a useful feature - what
do you think?

Marcus

---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: Intercepting Exceptions in Tapestry Listeners

Posted by Kent Tong <ke...@cpttm.org.mo>.
Schulte Marcus <marcus.schulte <at> bmw.ch> writes:

> Still, the way you have to unwrap your exception from the
> ApplicationRuntimeException is somewhat unsatisfactory. It's just too tight
> coupling to framework-internals. 

I suppose your user exceptions are checked exceptions? If
no, just override the activateExceptionPage() in BaseEngine.
If they're checked exceptions, why not create a Tapestry
listener wrapping your exception-throwing listener? Then
the Tapestry listener can catch the exceptions and display
the errors.



---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org