2009/6/19 Ian Petersen <[email protected]>
>
> On Thu, Jun 18, 2009 at 3:56 PM, Ian Bambury<[email protected]> wrote:
> > 2009/6/18 Thomas Broyer <[email protected]>
> >> Whether the eventbus has a reference to the widget is
> >> orthogonal.
> >
> > I didn't realise that widgets were bird-watchers! :-)
>
> Do you mean ornithologists?
Aren't they eye-doctors?
>
>
> Anyway, I think Thomas is talking about the presenter either being a
> widget or wrapping a widget. Widgets are notified when their elements
> are removed from the DOM, so you could conceivable make the presenter
> aware of the DOM detachment and use that as a convenient time to "get
> off the bus".
My (limited) understanding of what Ray Ryan was saying (and what I
understand of MVP) is that the presenter is completely separated from the
DOM elements (in order to facilitate testing, and because the view is solely
responsible for the view so you can swap views in and out as you please).
E.g. the example of a presenter would be something like this:
class PhoneEditor
{
Display display;
void bindDisplay(Display display)
{
this.display = display;
display.getSaveButton().addClickHandler(new ClickHandler()
{
@Override
public void onClick(ClickEvent event)
{
// doSave();
}
});
display.getCancelButton().addClickHandler(new ClickHandler()
{
public void onClick(ClickEvent event)
{
// doCancel();
}
});
}
interface Display
{
HasClickHandlers getCancelButton();
HasValue<String> getLabelPicker();
HasValue<String> getNumberField();
HasClickHandlers getSaveButton();
}
}
Or look at Sumit's example presenter here
http://code.google.com/webtoolkit/articles/testing_methodologies_using_gwt.html
The presenter isn't (or shouldn't be) a widget. It doesn't get notified of
any attachment or detachment because it has no way to know. It might be
swapping between two different views (?) and in any case, even if the view
is detached from the DOM, you may want it to be updated in case the user
switches back to it.
Ian
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---