1

I have a custom panel with a couple of components, eg. a button and a text box.

Once the button is clicked I would like custom panel that is also the parent panel receives the event and decides what to do, like call setText on the textbox.

Is it possible to achieve this using an eventbus ?

This means that the child components need not handle their event and then relay it.

Komal Goyal
  • 233
  • 5
  • 17
  • Why would you want to do that? You will have to write much more code than simply attaching handlers to your Button and TextBox. Typically, you need an EventBus when you have events that work across different views, or affect multiple widgets. – Andrei Volgin Feb 27 '14 at 15:52
  • EventBus is not the solution for this use case. You need to manage this logic in the Presenter. You add the ClickHandler on the button and then update what it should be updated in the OnClick method. Why you need to notify the panel ? – Momo Mar 01 '14 at 01:01
  • Possible duplicate of [How to use the GWT EventBus](http://stackoverflow.com/questions/6030202/how-to-use-the-gwt-eventbus) – Boris the Spider Jan 28 '16 at 15:19

1 Answers1

0

I don't know the exact classes and how they work together. But sure you could use the GWT EventBus to achieve this. Fire an event in your button class and handle this event in your custom panel. You can google or find related answers here on stackoverflow. I think this answer will help you: How to use the GWT EventBus

It's pretty simple to fire events and handle this events in other classes in your application.

Community
  • 1
  • 1