Search code examples
javagwtmvpgwt-mvp

How to implement a Compound View/Presenter for a GWT DecoratedTabPanel?


I'm new to GWT, and I've been reviewing the MVP implementation which uses the rpcService and the eventBus. I was wondering how a tab panel can be implemented such that each tab has its own sub-view. I have been waffling between making a custom widget that derives from a panel, or to figuring out how to make a presenter use another presenter, or to make a compound presenter class which handles it all for me.

Does anyone have advice on how to separate the functionality for each tab as opposed to keeping the implementation within one view/presenter pair?


Solution

  • I solved this without faking a main tab, but using the one provided with GWT's basic SDK. I did this by:

    1. Add an ArrayList of Presenters to the MainTabPresenter
    2. Constructed each tab's present plus view within the 'go' method of the MainTabPresenter
    3. Called 'go(null)' on each of the tab presenters.
    4. Handled the null situation on each.
    5. Implemented a method in the MainTabView to add the tabs to the DecoratedTabPanel

    It all works like a charm. The MainTabPresenter so very thin, and allows for complete implementations of View/Presenters to be written into their own files.