|
|
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: tapestry-user-unsubscribe@xxxxxxxxxxxxxxxxxx
For additional commands, e-mail: tapestry-user-help@xxxxxxxxxxxxxxxxxx
|
|