On May 12, 2005, at 2:56 AM, Schulte Marcus wrote:
BTW, I also mark my TA's for rollback when an exception is encountered - Do
you handle this in another place? - just curious.
Yes, I have an IMonitor to do that, but that really should be moved to my custom IActionListener wrapper now I think.
Erik
-----Urspr�ngliche Nachricht----- Von: Erik Hatcher [mailto:[EMAIL PROTECTED] Gesendet: Donnerstag, 12. Mai 2005 01:59 An: Tapestry users Betreff: Re: Tapestry's Simplicity Blues
On May 11, 2005, at 5:02 PM, Ben Eng wrote:
On Wed, May 11, 2005 at 11:36:39AM -0400, Erik Hatcher wrote:
There is not a way to intercept listener method invocations with HiveMind that I know of. If you know of a way, could you please share?
You don't like how I implemented events before and after listener invocation?
http://issues.apache.org/jira/browse/TAPESTRY-294
To be honest, I had forgotten about your patch.
Despite being a Tapestry committer, I typically try to solve problems without modification to the underlying frameworks (although I have usually ended up under the hood of most of the libraries I use). I've pasted, below, the hack I've used.
I would prefer if Howard signed off on your approach. I would think a more HiveMind-esque technique would be more to the Tapestry 4.0 style. I have no objections to what you've done. Though I'm not sure I'd be able to do what I've done with it, considering the way Page/RedirectException are handled. In your terms my post-listener event is fired only if the original listener succeed without thrown an exception or if throws Page/RedirectException. I don't think an "after" listener event could be coded in your contribution to do that. Please correct me if I'm wrong.
Throwing of an exception for flow control is something we should probably re-architect though.
Erik
public ListenerMap getListeners() { final ListenerMap orig = super.getListeners(); return new ListenerMap() {
public IActionListener getListener(String name) { final IActionListener origListener = orig.getListener(name); return new IActionListener() {
public void actionTriggered(IComponent component, IRequestCycle cycle) { RuntimeException e = null; try { origListener.actionTriggered(component, cycle); } catch (RedirectException re) { e = re; } catch (PageRedirectException pre) { e = pre; }
// only Tapestry's two flow control "exceptions" make it this far, and then are rethrown getDataContext().commitChanges();
if (e != null) throw e; }
}; }
public Collection getListenerNames() { return orig.getListenerNames(); }
public boolean canProvideListener(String name) { return orig.canProvideListener(name); } }; }
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
