dindeman
unread,Jul 2, 2011, 12:58:30 AM7/2/11Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to GWTP
Hi everyone.
I have a PresenterWidget whose constructor takes one @Assisted
argument:
@Inject
public MyPresenter(final EventBus eventBus, final MyView view,
@Assisted String param) {
super(eventBus, view);
...
}
and one factory
public interface MyPresenterFactory {
public MyPresenter create(@Assisted String param);
}
And the usual in ClientModule.configure()
install(new
GinFactoryModuleBuilder().build(MyPresenterFactory.class));
This would produce the following error at run-time:
[ERROR] [...] - Binding requested for constant key
Key[type=java.lang.String,
annotation=@com.google.inject.assistedinject.Assisted(value=)] but no
explicit binding was found.
I seriously scratched my head over that one and I ended up finding
that I HAD to use @AssistedInject for my GIN-assisted constructor.
But (as per Guice's documentation) @AssistedInject has to be used only
when there are multiple injectable constructors. So in order to make
the @AssistedInject'd one work, I had to provide another (regular
@Inject'd) constructor that in fact I don't need:
@AssistedInject
public MyPresenter(final EventBus eventBus, final MyView view,
@Assisted String param) {
super(eventBus, view);
...
}
@SuppressWarnings("unused")
@Inject
private MyPresenter(final EventBus eventBus, final MyView view) {
this(eventBus, view, "");
}
Does anyone know why that is?
I'm not sure that this is even a GWTP related issue but it's the only
context where it happened. I already had used @Assisted arguments with
factories before and I never had to do that.
Cheers.