I have an application where a set of custom composite widgets in the view 
have to know when each is clicked so the clicked widget can offer the user 
a red border to indicate the selection and also so that any previously 
selected widget can go back to being the normal color. These widgets can be 
added to the view dynamically by the user. This suggests to me that I 
should use an eventbus and custom events to represent this behavior. Every 
time I start trying to construct this however, I find myself wanting to 
reference the eventbus in the view (to fire a custom event with some 
identifier for the widget on click), but doing this feels like it could 
lead to problems.

I guess my questions are the following:
1. Can/should the view hold a reference to the eventbus, or can the 
application controller offer a static getter for the eventbus that the view 
can use to fire events on it?
2. Is there another way of handling this behavior that doesn't use the 
eventbus, such as a scheme for adding all the previously added widgets as 
handlers for the new widgets? This question makes me think that the 
eventbus really is the way to handle this.
3. One of my ideas included holding a reference to the eventbus in the 
custom event class as a static field, This way, a register static method 
could set the event bus and a fire static method could fire the event on 
the eventbus without any other classes needing to know about it. This seems 
like it's complicating the event too much, though.

Any thoughts?

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to