is there a way to use dependency injection in a widget, that is created via ui binding?
Suppose I have a simple widget (in package com.example.client.ui.widget):
public class Foo extends Composite {
private final EventBus eventBus;
@Inject
public Foo(final EventBus eventBus) {
this.eventBus = eventBus;
// create ui
}
}
and then I have a view that is defined via ui binding which uses this widget. eg:
<ui:UiBinder xmlns:ui='urn:ui:com.google.gwt.uibinder'
xmlns:g='urn:import:com.google.gwt.user.client.ui'
xmlns:app='urn:import:com.example.client.ui.widget'>
<g:HorizontalPanel>
<app:Foo/>
</g:HorizontalPanel>
</ui:UiBinder>
Doing it like this does not work, because of the no-arg constructor constraint for widgets that are used in ui binding. But wouldn't it be nice if the GWT compiler just uses GIN if there is an @Inject annotation? Or can this be done in any other way? Maybe I totally miss the concept of GIN and GWT, if so, any hints are much appreciated.
Thanks in advance, Markus