I have a new project where I am using GWT-Views like Composite, etc.
I have injected the items in the main menu (like ProductList
below) using GinInjector. This works fine!
Somewhere I want to have a reference from a small component to an item from my main menu in order to update it. I try to inject it this way:
public class ProductForm extends Composite {
...
@Inject
ProductList list;
....
}
But when I use the list
I always get null
. Whereby, ProductList
is defined this way:
public class MyModule extends AbstractGinModule {
...
@Override
protected void configure() {
bind(ProductList.class).asEagerSingleton();
bind(ProductForm.class).asEagerSingleton();
}
...
}
Any idea what I am doing wrong?!
Solution: I failed to mention that ProductForm is an element of the ProductList using the UIBinder's @UIField tag, So That injecting it will create a new object rather than the one created using UIBinder.
I had to restructure my code to include presenters and an event bus so that no direct references between views are needed (other than the @UIField attributes).