2011-09-19 41 views
1

我試圖用GWT-Platform做點什麼,但是,下面的示例在這個頁面中:http://code.google.com/p/gwt-platform/wiki/GettingStarted?tm=6簡單不起作用。GWT-Pratform的問題PlaceManager +杜松子酒

我得到了以下錯誤:

java.lang.AssertionError: Internal error, PlaceRequest passed to updateHistory doesn't match the tail of the place hierarchy. at com.gwtplatform.mvp.client.proxy.PlaceManagerImpl.updateHistory(PlaceManagerImpl.java:489) at com.gwtplatform.mvp.client.proxy.ProxyPlaceAbstract$3$1.execute(ProxyPlaceAbstract.java:208) at com.google.gwt.core.client.impl.SchedulerImpl$Task$.executeScheduled$(SchedulerImpl.java:50) at com.google.gwt.core.client.impl.SchedulerImpl.runScheduledTasks(SchedulerImpl.java:228) at com.google.gwt.core.client.impl.SchedulerImpl.flushPostEventPumpCommands(SchedulerImpl.java:388) at com.google.gwt.core.client.impl.SchedulerImpl$Flusher.execute(SchedulerImpl.java:78) at com.google.gwt.core.client.impl.SchedulerImpl.execute(SchedulerImpl.java:138) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103) at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71) at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172) at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessagesWhileWaitingForReturn(BrowserChannelServer.java:337) at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:218) at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:136) at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:561) at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:269) at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:91) at com.google.gwt.core.client.impl.Impl.apply(Impl.java) at com.google.gwt.core.client.impl.Impl.entry0(Impl.java:213) at sun.reflect.GeneratedMethodAccessor29.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103) at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71) at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172) at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessages(BrowserChannelServer.java:292) at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:546) at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:363) at java.lang.Thread.run(Unknown Source)

當我試圖做一個PlaceRequest。

我猜這是因爲注入了PlaceManager,而且有些時候它並不是單身人士,而是遵循wiki(http://code.google.com/p/gwt-platform/wiki/GettingStarted? TM = 6#Binding_everything_together):

Installing DefaultModule saves you from having to perform all the following bindings: bind(EventBus.class).to(SimpleEventBus.class).in(Singleton.class); bind(TokenFormatter.class).to(ParameterTokenFormatter.class).in(Singleton.class); bind(RootPresenter.class).asEagerSingleton(); bind(PlaceManager.class).to(MyPlaceManager.class).in(Singleton.class); bind(GoogleAnalytics.class).to(GoogleAnalyticsImpl.class).in(Singleton.class);

地方經理已經是一個單身......但是,它只是不工作。

有人有這個問題嗎?

回答

1

每次我得到這個異常,這是因爲我傳遞給updateHistory的PlaceRequest沒有與當前地點相同的NameToken,這是不合法的。
你想要做什麼?

+1

我試圖讓它去m#!home to#!adduser,但是,我認爲我做了一些錯誤的事情,下面的示例使用嵌套的演示程序。 – caarlos0

+0

然後,您不應該調用updateHistory(),而是嘗試使用revealPlace()。 –

+0

我使用的是揭幕(新的PlaceRequest(NameTokens.addUser))... – caarlos0

1

如果您正在使用GTWP 0.6,你可以使用DefaultModule這樣:

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

的DefaultModule需要綁定EventBus,TokenFormatter,RootPresenter,PlaceManager和Google分析的照顧。

+0

我已經這樣做了。 – caarlos0

3

在gwtp0.6剛剛出現這個問題時,我找到了解決方案。

的問題竟然是,我必將我的實現PlaceManager在ClientModule類:

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 ; 
    ...