The reason, why another class creats both and than puts the view into the presenter is called Dependency Injection. It is a widely used pattern, that means that you should inject dependencies into classes instead of using factories or doing something like 'new DependentClass()' in the constructor. In the best case, your presenter refers to a view interface and gets its view implementation injected.
The easiest way of doing Dependency Injection in GWT is GIN ( http://code.google.com/p/google-gin). It allows you to configure dependencies and let GIN do the creation of objects and put one into another at runtime. Dependency Inection is one of the best practices in GWT (and Java too) development (http://www.youtube.com/watch?v=PDuhR18-EdM) Regards Jan Ehrhardt On Mon, Jan 25, 2010 at 2:54 PM, rmuller <[email protected]> wrote: > Should not the Presenter create the view? > Sometimes you need different views (based on authorization data in my > case) where you can reuse the Presenter. I let the Presenter decide > which view to use. I do this in the ctor. > In all examples I see however, the Presenter and View are created by > the parent Presenter/AppContext. Also every View has its own Presenter > (1 : 1). So I wonder if my design is correct. > > What is the general opinion about this? > > Ronald > > -- > 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]<google-web-toolkit%[email protected]> > . > For more options, visit this group at > http://groups.google.com/group/google-web-toolkit?hl=en. > > -- 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.
