passing parameters from one presenter to another with GWT-Platform

不羁的心 提交于 2019-12-05 20:08:42

If the presenter should be loaded when the event is fired you can use a ProxyEvent. Have a look at http://code.google.com/p/gwt-platform/wiki/GettingStarted?tm=6#Attaching_events_to_proxies and http://arcbees.wordpress.com/2010/08/31/using-proxyevent/.

If you want to reduce coupling, you should create a custom event, CarLoadedEvent or something. Use GWTP Plugin for that, it works great. Then have your presenter that wants to catch that event implement CarLoadedHandler, and in its onBind() method, make it register to the eventBus :

@Override
protected void onBind() {
super.onBind();
registerHandler(getEventBus().addHandler(CarLoadedEvent.TYPE, this));
}

Finally, when a car is loaded, fire an event :

CarLoadedEvent.fire(getEventBus(), myLoadedCar);

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!