On Jan 12, 12:27 pm, ZER0 <[email protected]> wrote:
> Hi there,
>
> I'm using MVP pattern in a GWT project. So, I usually add the handler
> in the presenter, exposing from view the object through an interface
> like:
>
> HasClickHandlers getAddButton();
>
> Now I have a problem with FormPanel: I need to add a SubmitHandler to
> this object, but apparently there isn't any interface for that. I
> guess it's a lacks of GWT, probably due to moving from
> "FiresFormEvents" interface to the new approach.
>
> As far as I know, there are three options:
>
> 1) Create my own HasSubmitHandlers interface, my FormPanel class that
> only extend the original one and implements my HasSubmitHandlers
> interface.
> 2) Expose the Form object using the deprecated "FiresFormEvents"
> interface.
> 3) Add the submit handler in the view, and call a callback/command or
> whatever added by presenter
>
> So my question is: what's the good way to manage this kind of
> situation? There is something that I missed?
4) use an addFormSubmitHandler(FormPanel.SubmitHandler handler) on
your view, and just registers your SubmitHandler (which lives in your
presenter) that way (instead of using a "HasSubmitHandlers getForm()"
method and "getForm().addSubmitHandler(handler)" as you proposed in 1)
You usually have a single form per view so it's generally not a
problem to directly add the SubmitHandler "to the view"
And if you still wonder, the view can just delegate the call to the
FormPanel:
private FormPanel form;
public HandlerRegistration addFormSubmitHandler
(Formpanel.SubmitHandler handler) {
return form.addSubmithandler(handler);
}
--
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
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.