Tuesday, January 8, 2013

In MVP is there a difference between declaring the 'binding' interface in the presenter versus the view?

I saw a lot of sample code, most of them use the following way of creating MVP:

public interface ContactsView<T> {

  public interface Presenter<T> {
    void onAddButtonClicked();
    void onDeleteButtonClicked();
    void onItemClicked(T clickedItem);
    void onItemSelected(T selectedItem);
  }
  
  void setPresenter(Presenter<T> presenter);
  void setColumnDefinitions(List<ColumnDefinition<T>> columnDefinitions);
  void setRowData(List<T> rowData);
  Widget asWidget();
}


Then let the presenter implement ContactsView.Presenter<Contact>. However some do the following:


public class ContactsPresenter implements Presenter {  

  public interface Display {
    HasClickHandlers getAddButton();
    HasClickHandlers getDeleteButton();
    HasClickHandlers getList();
    void setData(List<String> data);
    int getClickedRow(ClickEvent event);
    List<Integer> getSelectedRows();
    Widget asWidget();
  }
//.........................
}

Then let the view implement the ContactsPresenter.Display.
Are there any good points for doing either methods, maybe one is better suited for UiBinder?


2- Another question, is the view not suppose to directly communicate with the model at all. For instance, if I've got a ListBox that should be populated from an Enum class that sits in the model, should that be done through the presenter?

--
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/-/MCtXV5RXLckJ.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

No comments:

Post a Comment