I’m creating a composite widget using UiBinder. The widget is a login form, so basicly it has labels, textboxes and a button. I’m planning to use this widget within a view which is also declared using UiBinder. So, basicly I’ve got these files: LoginForm.ui.xml, LoginForm.java, MainViewImpl.ui.xml and MainViewImpl.java.
I’d have to define the event handlers of the login form in LoginForm.java using the @UiHandler annotation, however I’d like to know if there is a way to define those event handlers in MainView.java. Is that possible?
No. That would break the component design pattern.
What you’d have to do is expose events on your
LoginFormcomponent that theMainViewImplwill be able to listen.If it’s a “one shot” though, I wouldn’t bother creating events and instead simply use a callback interface that
MainViewImplimplements and passes toLoginFormfor it to call it back.This is similar to the
Presenterinterface called back by the view in the MVP – Part II article to notify the presenter.