dependency injection - MVP GWT - problem injecting EventBus -
weird problem, when inject eventbus e got exception. project gwt using mvp
here sample code.
gin
public interface appginjector extends ginjector { eventbus geteventbus(); placemanager getplacemanager(); }
here 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 idea?
thanks
edit:
the exception is
error: deferred binding result type 'net.customware.gwt.presenter.client.eventbus' should not abstract. error: unable load module entry point class com.gmgsys.mvpentrypoint.client.mvpentrypoint (see associated exception details). java.lang.runtimeexception: deferred binding failed 'net.customware.gwt.presenter.client.eventbus' (did forget inherit required module?) ...........................
also gwt.xml
<!-- specify 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" />
i think missing abstractpresentermodule class makes sure eventbus bound simpleeventbus:
bind(eventbus.class).to(simpleeventbus.class).in(singleton.class);
it should that:
public class myclientmodule extends abstractpresentermodule { protected void configure() { bind(eventbus.class).to(simpleeventbus.class).in(singleton.class); // more bindings here } }
and have annotate ginjector
@ginmodules({ myclientmodule .class }) public interface appginjector extends ginjector { eventbus geteventbus(); placemanager getplacemanager(); }
Comments
Post a Comment