How to use UiHandler in a MVP pattern
Accoring to the MVP pattern the view should contain all the UI components. Then i read about the new UiHandler introduced in the GWT 2.0. The UiHandler can be used only in the view.
Should we 开发者_如何转开发use UiHandler in the mvp pattern, if so where should we use it.
NOTE: i am a GWT n00b.
Using gwt-presenter
, I can perfectly merge UiBinder with MVP. EventHandlers
are perfectly dividable in those that handle view events (entering a textbox clicks a submit button) and those that have their place in the presenters (handle service responses etc.)
In my opinion using UiHandler goes against the MVP as the view will have the logic for the event handling. The presenter should have this logic. However if you have the UiHandler methods only fire events that the presenters would handle you may have a nice middle ground.
There is a discussion about this at http://groups.google.com/group/google-web-toolkit/browse_thread/thread/ff40f7599fcc8709/da8901fe337f19b2?hl=en&lnk=gst&q=Mvp+uibinder#da8901fe337f19b2
Google has a very useful article up here on this exact topic, including sample code.
精彩评论