You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Ambiguous error when injecting with UIBinder and constructor parameters #115
What steps will reproduce the problem?
1. Create new UIBinder (creates class and .xml file) - e.g. MainPanel
2. Annotate MainPanel with @Singleton and it's constructor with @Inject and
otherwise prepare it to be injected.
3. Remove all ui elements and references to ui elements in the xml file and in
the MainPanel class. But leave the parameters in the MainPanel constructor
(e.g. "String firstName").
4. In entry point class, instantiate the injector and get MainPanel from the
injector.
5. run.
What is the expected output? What do you see instead?
I expect an intelligent error.
Instead, I get the following:
[ERROR] [helloworlds] Binding requested for constant key
Key[type=java.lang.String, annotation=[none]] but no explicit binding was found.
What version of the product are you using? On what operating system?
gin 1.0, jan 2010 on Ubuntu 10.04 32 bit
Please provide any additional information below.
And now in my MainPanel class:
@Singleton
public class MainPanel extends Composite {
...
@Inject
public MainPanel(String firstName) { // this is the offender!
...
And this the xml file for UIBinder:
<g:DockLayoutPanel unit="PX">
<g:center>
<g:HTML>center</g:HTML>
</g:center>
</g:DockLayoutPanel>
And in my EntryPoint class I do:
public final MyWidgetGinjector injector = GWT.create(MyWidgetGinjector.class);
And:
MainPanel mcp = injector.getMainPanel();
Clearly I'm wrong for leaving the parameter in a constructor of a class that is
being injected and not dealing with it, but the error received gave only an
ambiguous indication as to what the problem was. Something more helpful, like
"You have a non-zero argument constructor in the injected class: MainPanel. Get
rid of that argument!"
This would be especially helpful for people trying gin out for the first time
and altering the generated code from Eclipse and forgetting to delete a
constructor argument. (Especially since a quick search on Google yields only
links to the code.)
Original issue reported on code.google.com by rscottf...@gmail.com on 16 Aug 2010 at 2:58
Activity