posted 12 years ago
Hi all, I am new to GWT and I am looking into MVP1 architecture. I am learning from GWT documentation. I am going though the Contacts application.
I understood the flow and the need of having Presenter, View and AppController. But the thing which I dint understood is what is the need for having the Event classes and EventHandler classes under com.google.gwt.sample.contacts.client.event package?
For instance we can consider this code snippet from ContactsPresenter.javaWhen I click on Add button, new AddContactEvent() is being initialized. Already we binded this event with a event handler in AppController like thisthen addNewContact() method is called in which we are simply changing the History like thisWhat I don't understand is instead of writing all this code I can simply change the history from presenter method itself like thisWhy Should I use events and handlers approach instead?
On asking to one of my friends, he said that some times we might want to do some initialization before the view is actually loaded, there is a common central place(AppContoller) for every presenter to communicate. But I am not convinced with the answer.
Can anyone please shed some light and make it clear.
Thank you all, good day.
Love all, trust a few, do wrong to none.