GWT弃用:PlaceHistoryHandler.register? [英] GWT deprecated: PlaceHistoryHandler.register?

查看:134
本文介绍了GWT弃用:PlaceHistoryHandler.register?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个GWT应用程序,我将其移植到GWT 2.4。

I have a GWT app that I ported to GWT 2.4. Now I geta deprecated warning on this line:

 historyHandler.register(placeController, eventBus, defaultPlace);

来自类型PlaceHistoryHandler的方法寄存器(PlaceController,EventBus,Place)已弃用

"The method register(PlaceController, EventBus, Place) from the type PlaceHistoryHandler is deprecated"

有没有更好的方法来实现相同的结果,或者可以安全地忽略警告?

Is there a better way to achieve the same result here or is it safe to ignore the warning?

public void onModuleLoad() 
     {
          // Create ClientFactory using deferred binding so we can replace with
          // different impls in gwt.xml
          ClientFactory clientFactory = GWT.create(ClientFactory.class);
          EventBus eventBus = clientFactory.getEventBus();
          PlaceController placeController = clientFactory.getPlaceController();

          // Start ActivityManager for the main widget with our ActivityMapper
          ActivityMapper activityMapper = new AppActivityMapper(clientFactory);
          ActivityManager activityManager = new ActivityManager(activityMapper, eventBus);
          activityManager.setDisplay(appWidget);

          // Start PlaceHistoryHandler with our PlaceHistoryMapper
          AppPlaceHistoryMapper historyMapper = GWT.create(AppPlaceHistoryMapper.class);
          PlaceHistoryHandler historyHandler = new PlaceHistoryHandler(historyMapper);
          historyHandler.register(placeController, eventBus, defaultPlace);
          RootPanel.get().add(appWidget);

          // Goes to place represented on URL or default place
          historyHandler.handleCurrentHistory();
     }
    } 


推荐答案

方法已被废弃,因为 EventBus 类型已从 com.google.gwt.event.shared 移动到 com.google.web.bindery.event.shared 。如 JavaDocs中所述对于 PlaceHistoryHandler (这并不是特别清楚)将 EventBus 切换到 com.google.web.bindery.event.shared.EventBus 类型将解决弃用的警告。也就是说,现在, EventBus 类型在功能上是相同的,并且警告是安全的,无法忽略。

The method is deprecated because the EventBus type has moved from com.google.gwt.event.shared to com.google.web.bindery.event.shared. As indicated in the JavaDocs for PlaceHistoryHandler (which don't make this especially clear) switching your EventBus to the com.google.web.bindery.event.shared.EventBus type will resolve the deprecated warning. That said, for now, both EventBus types are functionally identical and the warning is safe to ignore.

这篇关于GWT弃用:PlaceHistoryHandler.register?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆