Hi Ricardo and Thomas, I don't know much about UIBinder (excepted that it seems promising and that I'll have to look into it!), but I might have an idea regarding the use of GIN / DI to improve upon Thomas' suggestion of: "revers[ing] the dependency and hav[ing] StatsView instantiate its StatsPresenter and keep a reference to it in a private field".
I got this idea the other day while reading this semi-related google- guice thread : http://groups.google.com/group/google-guice/browse_thread/thread/250923fe4e20a064 . What about: - adding a provider method in your GinModule: @Provides StatView provideStatView(StatPresenter statPresenter) { return statPresenter.getView(); } - then injecting the view where you need it: public MainView extends View { private final StatView statView; @Inject public MainView(StatView statView) { this.statView = statView; } } When Gin creates the MainView, it looks a StatView to inject, sees that it is provided by the @Provides method, creates and injects dependencies into a new presenter (including a new view associated to this presenter), and then returns the view. You can then inject multiple StatViews in your UI, and they will each create their associated presenter. If you want a singleton StatView, make the StatPresenter a singleton. In this case, the @Provides method will create the presenter the first time it is called, but will re-use this presenter (and associated view) the following times. You wouldn't even need to declare the StatView as a Singleton, because its scope would be the same as the StatPresenter's scope, due to the use of the @Provides method. In this case, your view would not have to instantiate your presenter / keep a reference to it. Gin does the magic for you. Which is IMO good for the separation of concerns. What do you think? Regards, Etienne --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
