Java 未处理Gwt总线事件
我正在与两位演示者合作,他们都使用gwt mvp设计模式,由一个视图组成。我在其中一个演示者(presenter1)中激发了一个事件,在第二个演示者中激发了一个事件处理程序。我遇到的问题是从未调用处理程序。我正在使用客户端工厂注入事件总线实例Java 未处理Gwt总线事件,java,gwt,mvp,Java,Gwt,Mvp,我正在与两位演示者合作,他们都使用gwt mvp设计模式,由一个视图组成。我在其中一个演示者(presenter1)中激发了一个事件,在第二个演示者中激发了一个事件处理程序。我遇到的问题是从未调用处理程序。我正在使用客户端工厂注入事件总线实例 private static EventBus eventbus; private static SystemServiceAsync rpc; @Override public EventBus getEventBus() { if (ev
private static EventBus eventbus;
private static SystemServiceAsync rpc;
@Override
public EventBus getEventBus() {
if (eventbus == null) eventbus = new SimpleEventBus();
return eventbus;
}
第二个演示者中的处理程序
this.eventBus.addHandler(AskQuestionEvent.getType(), new AskQuestionHandler() {
@Override
public void onQuestionAskEvent(AskQuestionEvent event) {
Window.alert("new ");
checkForNewQuestion();
}
});
在第一个演示者中,我呼叫
eventBus.fireEvent(new AskQuestionEvent());
两个演示者都将eventbus注入其构造函数中
private final EventBus eventBus;
public PresenterImpl(final View view){
this.rpcService = clientFactory.getRpcServices();
this.eventBus = clientFactory.getEventBus();
bind();
}
如果将处理程序放置在同一个演示者中,则会调用该处理程序,但如果在另一个演示者中,则不会调用该处理程序。这里可能有什么问题?我看不出有什么理由不起作用。您能否在调试模式下检查两个演示者是否具有相同的
EventBus
实例?是的,也许clientFactory不是单例,而是具有不同的EventBus。