We've been using the recommended GWT approach of building parts of our application in an MVP manner. The logic we use is based on Google's examples - the Presenter fetches/prepares data and sets it on the View, and the View contains a reference to the Presenter which it calls (e.g. in UiHandlers).
Some parts of the application which we built should be reused in other views. For example - a view which is sometimes the "main view" of a part of the application - can be used inside a pop-up in another part of the application (of course, the views/presenters are initialized differently in this other case, but basically it is the same thing).
What would be the correct approach to do stuff like this? I cannot seem to find a suitable one without resorting to ugly hacky stuff.
For example - if I put the presenter of the reused component inside the main view - it is easy to initialize the reused component, but it is ugly to receive a result back in the main presenter. This can be solved by passing a runnable or creating a custom handler or passing the parent presenter itself to the reused presenter.
All of these approaches don't seem right to me though and seem ugly. Any ideas/experiences?
EventBusand directly calling components/presenters. I don't have really an example at the hand. But as a general guideline I wouldn't use the globalEventBusfor UI components. I would handle all the events and state changes of the UI component in the View that contains it. The View can callback on the presenters which might do some additonal logic or fire an Event on the globalEventBusif another part of the app/presenter has some interest in the state change of the UI component. - Ümit