I am creating a multi-module project with a single entry point class but has some issues,
I have 2 modules as :-
This is my main module,
@ChildModule(moduleClass = MyChildModule.class)
public class MyMainModule implements EntryPoint {
@Override
public void onModuleLoad() {
Mvp4gModule module = (Mvp4gModule) GWT.create(Mvp4gModule.class);
module.createAndStartModule();
RootPanel.get().add((Widget) module.getStartView());
}
}
and created a child module as,
public interface MyChildModule extends Mvp4gModule {
}
My base eventBus is,
@Events( startPresenter = HomePresenter.class,historyOnStart=true)
@ChildModules(@ChildModule(moduleClass=MyChildModule.class, async=true, autoDisplay=false ))
public interface BaseEventBus extends EventBusWithLookup {
@InitHistory
@Event(handlers = HomePresenter.class)
void init();
@Start
@Event(handlers = HomePresenter.class)
void start();
@Event(forwardToModules=MyChildModule.class)
void getContentBody();
@Event(handlers = HomePresenter.class)
void setContentBody(ContentBodyView contentBodyView);
}
and child event bus is,
@Events(module=MyChildModule.class, startPresenter = ContentBodyPresenter.class)
public interface MyChildEventBus extends EventBusWithLookup {
@Event(generate = ContentBodyPresenter.class)
void getContentBody();
@Event(forwardToParent=true)
void setContentBody(ContentBodyView contentBodyView);
}
HomePresenter, HomeView are in MyMainModule and ContentBodyPresenter,ContentBodyView are from MyChildModule.
@Presenter(view = HomeView.class)
public class HomePresenter extends BasePresenter<HomeView, BaseEventBus>{
getErrorBtn().addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent arg0) {
eventBus.showError("Error");
}
});
}
the above presenter accessing BaseEventBus and ContentBodyPresenter is as followa,
@Presenter(view = ContentBodyView.class)
public class ContentBodyPresenter extends BasePresenter<ContentBodyView, MyChildEventBus>{
getErrorBtn().addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent arg0) {
eventBus.showError("Error");
}
});
}
here if I access eventbus it will still accessing BaseEventBus event if I specified MyChildEventBus above. Why is it so.?
and I inherited the MyChildModule in gwt.xml of MyMainModule as,
<inherits name='abc.xyz.MyChildModule' />
If I compile this project, am getting deferred binding error for MyChildModule and console shows Method getContentBody: No instance of client.MyChildModule is defined. Have you forgotten to add it to @ChildModules of your event bus interface?. What can be the issue.? Is there any structural flaw in above code.?