Hi,
I am using GIN + MVP + UiBinder so I end up with having:
- MyView.java (Interface, extends IsWidget)
- MyViewImpl.java (UiBinder, implements MyView)
Now when I want to use MyView inside a different UiBinder widget I inject the interface and use it along with @UiField(provided = true).
That works great but as a little downside I have to re-declare Widget methods in my MyView interface if I want to call them directly in UiBinder, e.g. setWidth/setHeight/setStyleName.
For setter methods that also works, but now I need to add some styles to MyView. In UiBinder you would normally do <my:MyView addStyleNames="list of styles"/> but that fails in case of my view interface (error is: setAddStyleNames() is not declared). Actually UiBinder special treats "addStyleNames" for normal widgets (it works with <my:MyViewImpl addStyleNames=...>) but it stops doing so when it sees something that does not extend Widget I guess. To solve this I am forced to create an Interface for my UiBinder inline CssResource just to be able to do: myView.asWidget().addStyleName(..).
How do you guys work with view interfaces in UiBinder? Are there better ways than mine?
My proposed RFE for UiBinder would be that UiBinder recognizes interfaces that extend IsWidget and then generates code that delegates to view.asWidget().method() as long as "method()" is available in Widget or UiObject class. Any opinions?
-- J.