Hi all.

I've been trying to use the UIBinder, i like it a lot. At the same
time i've replaced my own MVP implementation with gwt-presenter (which
is cleaner than what i had), but there's one bit i can't figure out by
myself regarding dependency injection with GIN.

I have a MainPresenter which is retrieved by the injector interface
after i instantiate the injector. This one instantiates the
corresponding MainView using DI, and the actual layout is defined in a
UiBinder xml file. This works fine, until i try to add another of my
View objects into the MainView UiBinder file. Something like:
<gwt:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
   ...
   xmlns:stats="urn:import:my.package.for.statistics">
     ...
     <stats:StatsView ui:field="statsView"/>
     ...
</gwt:UiBinder>

One question and one issue.

1) How do you instantiate your Presenter objects? I have a
StatsPresenter for the StatsView, but if i simply use the UiBinder
like in here, it will never be instantiated. I've 'fixed' this by
adding a reference to this StatsPresenter from the MainPresenter -
which is injected - but only so that one is created, it's not like i
need that reference there.

2) Given my solution above, i need to make sure that the StatsView is
a singleton, otherwise the Presenter instantiates a new StatsView
which is different from the one created by the UiBinder. Again i try
to use dependency injection by defining in the MainView a StatsView
field as in:

    @UiField(provided=true)
    StatsView statsView;

I then add in my injector:
bind(StatsView.class).in(Singleton.class);

but either this or using a Provider method instead gives me the
following:
00:01:18.766 [ERROR] Failed to create an instance of 'MainView' via
deferred binding java.lang.NullPointerException: null at
com.google.gwt.user.client.ui.ComplexPanel.add(ComplexPanel.java:77)
at com.google.gwt.user.client.ui.VerticalPanel.add(VerticalPanel.java:
53) at
...

Any hints on this? I can't figure out what i'm doing wrong.

Thanks a lot in advance,
  Ricardo
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to