0
votes

Im new to GWT, this should be a simple question i hope.

Imagine that i made two Uibinders Modules or two independent widgets.(this a simplify example to expose my problem)

one is a set of buttons (ButtonPanel) and the other image to been show when i press a button from the previous panel(ImagePAnel) with a label to be the title of the image.

How can i reach the wiget the imagePanel to actuate when there are a handler click from the buttons in the (ButtonPanel)

Thanks for the help.

3

3 Answers

0
votes

I recommend you to use MVP Pattern for Development and add all events in the Presenter.

Or Else you can use the following technique within the UIBinder's Java File

@UiHandler(value={"openButton"})
public void onOpenButtonClick(ClickEvent clickEvent){
      //ADD THE BUTTON LOGIC HERE
}

Just Create an Object of the Images & the ImagePanel to be loaded and add it on button click using this.

0
votes

I can't say I understand exactly what you are trying to accomplish but in general the best way for different components in a GUI application to communicate is to use the eventbus pattern. There's one global Eventbus object in the application that lets components subscribe to a specified type of event that are fired from any place in your application. This way you avoid spaghetti code and your components are loosely coupled.

http://code.google.com/webtoolkit/articles/mvp-architecture.html#events

0
votes

I typically create a third component that is the container for the Button and Image components you defined. This component sets itself as a callback for the two and contains logic to integrate the two.