Hi,
FYI.
In the end I managed to have a working solution for altering the
behaviour of event bubbling (limited to void, boolean and null values).
My solution that I really do not appreciate so much... consists in:
- Provide an annotation: @StopBubbling
- Copy+Paste+Modify the OnEventWorker and do the following mods:
- at the beginning recover all the methods with the annotation
(blocked methods)
- for all the blocked methods wrap the contextEvent in a new class to
force the event.isAborted to a true value, and the storeResult to
store a wrapped Boolean, Null or Void.
- Provide a contribution to ComponentEventProcessor to deal with the
new types of objects
On Oct 24, 2010, at 7:54 PM, Howard Lewis Ship wrote:
The boolean logic is hard coded; perhaps you should think in terms of
a enum to return instead.
On Sat, Oct 23, 2010 at 11:29 PM, Alessio Gambi <agamb...@gmail.com>
wrote:
Hi,
I would like to return a boolean value form the handler instead of
using the
value of the boolean itself to control the bubbling process
(actually the
same applies to void).
For this purpose, I defined an annotation to prevent events to
bubble for
the annotated event handler methods, and a
ComponentClassTransformationWorker.
The first idea was to let the worker to modify the return value of
the
original method to something wrapping the boolean (and the void) and
override its result. Unfortunately I did not find a way to do that.
The next idea is to add a new eventHandler method that listen for
the same
events/components of the original one, it basically wraps the body
of the
original method using an advide.
The problem now is to "register" this new method with the
dispatcherMethod.
I think the best way is to annotate the method with the OnEvent
annotation
and name it something like:
_+originalMethod name
In this way, this method should be always called before the
original one,
always produces an Object that stops the bubbling, and always
invoke the
same logic as the original method.
The problem: I cannot find a way to add the annotation to a generated
method.
In another possibility, I can name the new method with something like
on+MethodName. But, I do not remember if the annotation takes
precedence
over the naming convention.
Anyway, this solution is not so clean (and there may be clashes or
method
duplications).
Any advice ?
BTW, I am using 5.2
Thank you.
-- Alessio
PS: As far as possible, I would like the OnEventWorker to register
handler
methods in the component event dispatcher.
--
Howard M. Lewis Ship
Creator of Apache Tapestry
The source for Tapestry training, mentoring and support. Contact me to
learn how I can get you up and productive in Tapestry fast!
(971) 678-5210
http://howardlewisship.com
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org