On 24 oct, 23:54, "fker...@gmail.com" <fker...@gmail.com> wrote:
> I have been 
> studyinghttp://blog.appenginefan.com/search/label/Schluesselmeister
> application, and that got me to thinking about MVP... In that example,
> "Display" is about the same as "View", and "Controller" is like
> "Presenter". You inject the View to the Presenter through its
> constructor... but then the Presenter injects itself into the View by
> doing something like View.setPresenter(this);
>
> There are benefits, but having the View know about the Presenter seems
> odd.
>
> You could have:
> LoginPresenter.View interface:
>     String getName( );
>     String getPass( );
>     void setPresenter(Presenter p);
>
> LoginView.Presenter interface:
>     tryToLogin( )
>
> LoginPresenter implements LoginView.Presenter with something like:
>     // call a remote service with myView.getName( ) and myView.getPass
> ( )
>     // on callback, if the service agrees, initialize everything, show
> the menu, etc.
>
> LoginView implements LoginPresenter.View with something like:
>     // add a click handler to its "login" button
>     // which will call presenter.tryToLogin( )
>
> The LoginPresenter constructor looks like
>     LoginPresenter(LoginView view ...and some other parameters...)
>         myView = view;
>         myView.setPresenter(this);
>         ...
>
> This way of implementing things doesn't require sending events from
> the view to the presenter, or the presenter providing callbacks to the
> view... but somehow looks weird to me... any thoughts on it?

I'd rather use the following, though I understand why the
LoginView.Presenter interface could help with mocking (it's easier to
mock the view then, because you don't have to mock HasClickHandlers
and eventually HandlerRegistration and ClickEvent):
LoginPresenter.View interface:
   String.getName()
   String getPass()
   HasClickHandlers getSignInButton()

The LoginPresenter constructor looks like:
   LoginPresenter(LoginView view ...and some other parameters...)
      this.view = view;
      view.getSignInButton().addClickHandler(new ClickHandler() {
         public void onClick(ClickEvent event) {
            tryToLogin();
         }
      });

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to