0
votes

I am looking at this GWT MVP tutorial:

http://www.gwtproject.org/articles/mvp-architecture.html#binding

The data is passed from the presenter to the view using this method:

display.setData(data);

where data is ArrayList<String>

How would I pass the data between view and presenter if I had something like a SelectBox in my view where I can select multiple values that I probably populate from a database?

I would store the SelectBox values probably in a HashMap.

Should I implement a second method to pass this to the presenter or should I try to keep the communication between view and presenter down to just one method?

In essence: How can views and presenters communicate through a simple method that ideally takes only one parameter, taking into consideration that sometimes I need to pass a simple string which represents an e-mail address and sometimes something more complex such as the values of a SelectBox?

1

1 Answers

0
votes

You can add as many methods as you like to make your communication between your VIEWS & PRESENTERS! The key point lies in the choice of your methods and the implementation, because, debugging a GWT code-base is a nightmare!

There are approaches that you could choose from:

  1. You can have a DISPLAY interface of your PRESENTER be implemented on your VIEW
  2. You could generate an event (on MULTI-SELECT of Values from your SelectBox on VIEW), implement a corresponding handler on your PRESENTER to overcome multiple methods that need to be put in your DISPLAY interface!

Choose your option, based on your requirement and also on the complexity of it! My suggestion is to have an event, since the same piece of code can be reused somewhere else as well!