I've also been trying to wrap my head around GWT MVP and have started
blogging about my reading/playing here:
http://howtogwt.blogspot.com/

- Eric


On Feb 15, 5:20 am, Eric <[email protected]> wrote:
> It would be great if someone would post a non-trivial example ofMVP.
> I have struggled extrapolating from the Contacts App into more complex
> arrangements.  I am by no means an authority, so please correct me.
>
> My first take away was that their were a few rules:
> 1) Presenters don't know about specific GWT widgets (so that you can
> test your business logic without GWTTestCase)
> 2) Displays don't know about business logic
> 3) Displays don't know about application logic
> 4) Displays don't know about model classes
>
> I still consider the first 3 to be sacrosanct, but I have pretty much
> dropped rule #4.  I don't see a conceptual difference between a String
> and a Contact.  It seems silly to write code like:
> for ( int i = 0 ; i < name.length ; i++ ) {
> if ( active[i] ) { ... do stuff... }
> if ( email[i] != null ) { ...do stuff...}
> myPanel.add( name[i] ) ;
>
> }
>
> when I could just write:
> for ( Contact contact : contacts ) {
>   if ( contact.getActive() ) { ... }
>   if ( contact.getEmail() != null ) { ... }
>   myPanel.add( contact.getName() ) ;
>
> }
>
> For one thing the first way of doing it makes your code more sensitive
> to changes in your model.  If I add or rename a field in my model I
> have to edit my presenter to make another parallel array instead of
> just having the new field available to display.
>
> I would definitely agree that an operation like sorting should be done
> in the presenter, but then it should call
> "display.setContacts(contacts)" with the new sorted list.  Similarly
> at first I had a rule that displays wouldn't attach any event
> handlers, but now I allow fairly trivial event handlers (those that
> just do a "History.addItem()").  I have still enforced a rule against
> the display having a handle to the event bus, but my resolve is
> wavering on that as well.
>
> Eric
>
> On Feb 15, 3:06 am, Jan Ehrhardt <[email protected]> wrote:
>
>
>
> > The presenter does sorting, mapping etc. The view even has no direct
> > dependency to the presenter. If the view requires to notify the presenter,
> > it will have to fire an event to the presenters event handlers.
>
> > In your case, it would be cleaner to put the information, which contact will
> > be displayed in wich row, into the presenter. The presenter should fill each
> > table cell, while the table doesn't know anything about its content.
>
> > You can think of the view as the most stupid part of your application. The
> > view only does initalization and layout of the ui components, that's it. It
> > provides methods to access some of the components like text field or labels,
> > but all the logic is in the presenter.
>
> > Regards
> > Jan Ehrhardt
>
> > On Sun, Feb 14, 2010 at 10:02 PM, Yaakov <[email protected]> wrote:
> > > Hi all,
>
> > > Am I correct in my understanding that the View NEVER has any
> > > dependencies on the model? I.e., whatever sorting, mapping, etc needs
> > > to be done between the view and the data, it's the Presenter that
> > > holds the real data and just sets simple strings to the View?
>
> > > So, following this and the Contacts example on GWT site, it would be
> > > **incorrect** to create a ContactsFlexTable that would keep track of
> > > which Contact is assigned to which row index in the table, right?
>
> > > Thanks,
> > > Yaakov.
>
> > > --
> > > 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%2Bunsubs
> > >  [email protected]>
> > > .
> > > For more options, visit this group at
> > >http://groups.google.com/group/google-web-toolkit?hl=en.- Hide quoted text 
> > >-
>
> - Show quoted text -

-- 
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.

Reply via email to