1

我试图用 GWT 平台做一些事情,但是,按照本页中的示例:http ://code.google.com/p/gwt-platform/wiki/GettingStarted?tm=6 simple 不起作用。

我收到以下错误:

java.lang.AssertionError:内部错误,传递给 updateHistory 的 PlaceRequest 与位置层次结构的尾部不匹配。在 com.gwtplatform.mvp.client.proxy.PlaceManagerImpl.updateHistory(PlaceManagerImpl.java:489) 在 com.gwtplatform.mvp.client.proxy.ProxyPlaceAbstract$3$1.execute(ProxyPlaceAbstract.java:208) 在 com.google.gwt .core.client.impl.SchedulerImpl$Task$.executeScheduled$(SchedulerImpl.java:50) 在 com.google.gwt.core.client.impl.SchedulerImpl.runScheduledTasks(SchedulerImpl.java:228) 在 com.google.gwt .core.client.impl.SchedulerImpl.flushPostEventPumpCommands(SchedulerImpl.java:388) 在 com.google.gwt.core.client.impl.SchedulerImpl$Flusher.execute(SchedulerImpl.java:78) 在 com.google.gwt.core .client.impl.SchedulerImpl.execute(SchedulerImpl.java:138) 在 sun.reflect。

当我尝试发出 PlaceRequest 时。

我猜它的发生是因为 PlaceManager 被注入了,而且,它不是单例,而是遵循 wiki (http://code.google.com/p/gwt-platform/wiki/GettingStarted?tm=6# Binding_everything_together):

安装 DefaultModule 使您不必执行以下所有绑定: bind(EventBus.class).to(SimpleEventBus.class).in(Singleton.class); bind(TokenFormatter.class).to(ParameterTokenFormatter.class).in(Singleton.class); 绑定(RootPresenter.class).asEagerSingleton();绑定(PlaceManager.class).to(MyPlaceManager.class).in(Singleton.class);绑定(GoogleAnalytics.class).to(GoogleAnalyticsImpl.class).in(Singleton.class);

地方经理必须是单身人士......但是,它根本不起作用。

有人有这个问题吗?

4

3 回答 3

3

刚刚遇到 gwtp 0.6 的这个问题,我找到了解决问题的方法。

问题原来是我在 ClientModule 类中绑定了 PlaceManager 的实现:

  protected void configure() {
    // Singletons
    install(new DefaultModule(ClientPlaceManager.class));
    ...

然后在演示者构造函数中自动绑定我的相同实现

  private ClientPlaceManager placeManager ; //wrong - should be the interface

  @Inject
  public FrameworkLayoutPresenter(final EventBus eventBus, final MyView view, final MyProxy proxy, 
      final ClientPlaceManager placeManager) //wrong - should be the interface
  {
    super(eventBus, view, proxy);
    this.placeManager = placeManager ;
    ...

但我应该绑定接口 PlaceManager

  private PlaceManager placeManager ; 

  @Inject
  public FrameworkLayoutPresenter(final EventBus eventBus, final MyView view, final MyProxy proxy, 
      final PlaceManager placeManager) 
  {
    super(eventBus, view, proxy);
    this.placeManager = placeManager ;
    ...
于 2012-02-26T07:38:19.733 回答
1

每次我得到这个异常,都是因为我传递给updateHistory的PlaceRequest没有和当前地点一样的NameToken,这是不合法的。
你到底想做什么?

于 2011-09-20T07:54:01.547 回答
1

如果您使用的是 GTWP 0.6,您可以通过以下方式使用 DefaultModule:

public class ClientModule extends AbstractPresenterModule {
    @Override
    protected void configure() {
         install(new DefaultModule(MyPlaceManager.class));
}

DefaultModule 负责绑定 EventBus、TokenFormatter、RootPresenter、PlaceManager 和 GoogleAnalytics。

于 2011-09-20T08:23:30.780 回答