Reputation: 423
Weird problem, when i inject EventBus e got an exception. The project is gwt using mvp
Here is the sample code.
Gin
public interface AppGinjector extends Ginjector
{
EventBus getEventBus();
PlaceManager getPlaceManager();
}
Here is the entry point
public class MvpEntryPoint implements EntryPoint
{
AppGinjector ginjector = GWT.create(AppGinjector.class);
public void onModuleLoad()
{
EventBus eventBus = ginjector.geEventBus();
HelloWorldPanel display = new HelloWorldPanel();
HelloWorldPresenter presenter = new HelloWorldPresenter( display, eventBus );
presenter.bind();
RootPanel.get().add( presenter.getDisplay().asWidget() );
PlaceManager placeManager = ginjector.getPlaceManager();
placeManager.fireCurrentPlace();
}
i use gin 1.0 , gwt-presenter
Any has any idea?
Thanks
Edit:
The exception is
ERROR: Deferred binding result type 'net.customware.gwt.presenter.client.EventBus' should not be abstract.
ERROR: Unable to load module entry point class com.gmgsys.mvpEntryPoint.client.MvpEntryPoint (see associated exception for details). java.lang.RuntimeException: Deferred binding failed for 'net.customware.gwt.presenter.client.EventBus' (did you forget to inherit a required module?)
...........................
also the gwt.xml
<!-- Specify the app entry point class. -->
<entry-point class='com.gmgsys.mvpEntryPoint.client.MvpEntryPoint'/>
<inherits name='net.customware.gwt.presenter.Presenter' />
<inherits name="com.google.gwt.inject.Inject" />
Upvotes: 2
Views: 2143
Reputation: 17489
I think you are missing the AbstractPresenterModule class which makes sure that EventBus is bound to SimpleEventBus:
bind(EventBus.class).to(SimpleEventBus.class).in(Singleton.class);
It should be something like that:
public class MyClientModule extends AbstractPresenterModule {
protected void configure() {
bind(EventBus.class).to(SimpleEventBus.class).in(Singleton.class);
// more bindings here
}
}
And you have to annotate your Ginjector
@GinModules({ MyClientModule .class })
public interface AppGinjector extends Ginjector
{
EventBus getEventBus();
PlaceManager getPlaceManager();
}
Upvotes: 4