for listening on events on your widget you can define UiHandler or Attach /
Add handlers
for example, if you have a button defined in your UIBinder
<g:Button ui:field = 'button1'>Hello</g:Button>
now if you want to listen on click event of this button, you can do either
of these two operations
@UiHandler("button1")
public void OnButton1Click(ClickEvent event) {
///do what ever you want on button click
}
when you are not using a UiBinder you can define
button1.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent arg0) {
//do your opertaions
}
})
hope this is clear.
Thanks
Ashwin
On Sun, Jun 26, 2011 at 4:40 AM, isern <[email protected]> wrote:
> I come from the Flex/JS/Tapestry worlds and a technique commonly used
> is to attach listeners to certain events expecting they'll will go up
> like a bubble through the component hierarchy. Actually if I'm not
> wrong this kind of behavior also occurs with native hardware events in
> GWT.
>
> A typical example is the Accept/Cancel widget. It's a widget because
> it's repeated all over the application.
>
> To reduce coupling to a minimum, I'd like to listen to the events
> "accept" and "cancel" on the current widget (that contains accept/
> cancel directly or indirectly), being aware that if users click
> "accept" the event will be caught and what you do depends on that
> context (UI structure)
>
> The EventBus is okay, but it doesn't seem to take into account this
> component hierarchy, all the event handlers are notified without
> discrimination.
>
> I've managed, however, to create a BubbledEvent/BubbledEventHandler
> that only is dispatched if the current listener (a visual widget) is a
> parent of that which triggered it.
>
> I hope I was clear,
>
> Best regards, Juan
>
> On Jun 25, 3:34 am, Ashwin Desikan <[email protected]> wrote:
> > what sort of events are you looking to capture? You can create custom
> events
> > and register those events with the eventBus. When ever that event occurs
> all
> > handlers would receive a notification and you can take necessary action.
> >
> > Thanks
> > Ashwin
>
> --
> You received this message because you are subscribed to the Google Groups
> "Google Web Toolkit" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/google-web-toolkit?hl=en.
>
>
--
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-web-toolkit?hl=en.