GWTP
GWTP copied to clipboard
Could not add Places to History when using RouteTokenFormatter
In my ClientModule I bind the RouteTokenFormatter as:
install(new DefaultModule(DefaultPlaceManager.class, RouteTokenFormatter.class));
My NameTokens are like this:
public static final String user = "/user/{userId}";
When I reveal a place I do
PlaceRequest request = new PlaceRequest.Builder()
.nameToken(NameTokens.getUser())
.with("userId", 123)
.build();
placeManager.revealPlace(request);
This works great, but I do not get anything on the history stack. placeManager.getHierarchyDepth() returns alway one in this case. So I tried to use:
placeManager.revealRelativePlace(request);
Using the former I get the following error:
00:23:57.655 [ERROR] [mobile] Uncaught exception escaped
java.lang.AssertionError: Expected a place hierarchy with exactly one place.
at com.gwtplatform.mvp.client.proxy.RouteTokenFormatter.toHistoryToken(RouteTokenFormatter.java:238)
at com.gwtplatform.mvp.client.proxy.PlaceManagerImpl.updateHistory(PlaceManagerImpl.java:493)
at com.gwtplatform.mvp.client.proxy.ProxyPlaceAbstract$3$1.execute(ProxyPlaceAbstract.java:277)
at com.google.gwt.core.client.impl.SchedulerImpl$Task$.executeScheduled$(SchedulerImpl.java:50)
at com.google.gwt.core.client.impl.SchedulerImpl.runScheduledTasks(SchedulerImpl.java:180)
at com.google.gwt.core.client.impl.SchedulerImpl.flushPostEventPumpCommands(SchedulerImpl.java:347)
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(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
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:338)
at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:219)
at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:136)
at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:571)
at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:279)
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:242)
at sun.reflect.GeneratedMethodAccessor823.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
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:293)
at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:547)
at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:364)
at java.lang.Thread.run(Thread.java:722)
Then I tried this:
placeManager.buildRelativeHistoryToken(request);
And I got the same error.
Since I did everything like in the GWTP-Samples I suppose this is a bug in GWTP?
Or is there another way to add places to the history when using RouteTokenFormatter?
I created a demo project to show this issue. You can found it here: https://github.com/confile/gwt-history
May be I am wrong, but what I want to do is the following. In my app I want to show a back button if the user has navigated to at least one other place from the starting place. I though that placeManager.getHierarchyDepth() will indicate how many places the user has been visited. Isn't that the case?
Could you try it with GWTP 1.2.1 and tell us if you still have this issue?
@confile do you still have this issue?
@olafleur Yes this problem is still open. I think this is by design that for RoutePlace tokens GWTP does not add entries on the history stack. So placeManager.getHierarchyDepth() remains always one.
@Chris-V @christiangoudreau do we want to change that?
To be honest, we rarely use Hierarchical Places, but it would be a very nice addition nonetheless. Because of the changes it may imply, I'm not sure we are ready to do that before GWTP 2 though.
Do we have public roadmap for GWTP 2.0? If we do want this feature, we could write that down in a roadmap and close that issue. What do you think @Chris-V ?
We don't even have a "private" roadmap :D
Here's a suggestion, then. ;-) Imho, open issues in Github should be for "actual know problems" for the framework. We should aim to close issues that are suggestions of new features in one of two ways : yes, we want that feature, and we write that down in some kind of road map or no, we don't want that feature, it's not in the scope of our framework.
What do you think?
Well, issues are also a way to vote features. That's one of the goal to keep them alive
Ok, I understand. ;-)
Well we do have goals for 2.0. Although it's not formally written, I would consider this the private roadmap.