Hi all,

I'll have to set the basics for a in-house framework and can't make my mind 
on the basic Presenter interface. Is it better to use HasWidgets or 
AcceptsOneWidget ? This would lead to:


public interface Presenter {
  public void go(final HasWidgets container);
}

or

public interface Presenter {
  public void go(final AcceptsOneWidget container);
}

The former is more generic I think but you always have to think about 
adding the line container.clear() in your implementations. In the latter, 
it's more straightforward (container.setWidget(myView) ) and it is clearer 
as it's enforce the responsibility on the depper Presenter to provide only 
one widget. It's his responsability to group every widget into one 
container before calling setWidget().
I prefer the latter but it seems that more components implement HasWidgets 
so in the end the former would be easier to developp. What do you think ?

For the record, I was forced to develop a wrapper 
(HasWidgetsToAcceptsOneWidgetWrapper) in order to pass the RootLayoutPanel 
to my first Presenter using the latter method. Here's the dirty code:
public class HasWidgetsToAcceptsOneWidgetWrapper implements 
AcceptsOneWidget {
    private HasWidgets wrapped;

    public HasWidgetsToAcceptsOneWidgetWrapper(HasWidgets wrapped) {
        this.wrapped = wrapped;
    }

    public void setWidget(IsWidget widgetToAdd) {
        wrapped.clear();
        wrapped.add(widgetToAdd.asWidget());
    }

}

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/google-web-toolkit/-/cUn4UUU-qn8J.
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