I'm using History. Below is the code from my onModuleLoad(). I added the
fireCurrentHistoryState() call as you suggested (thank you), but I'm having
the same problem. After a refresh on a different page, I'm returned to the
main page, where I click the same button. The click handler calls
History.newItem("Foo");
but my valueChangeHandler doesn't get invoked.
public void onModuleLoad() {
clientFactory = ClientFactoryImpl.getInstance();
// If the application starts with no history token, redirect to a new
state.
String initToken = History.getToken();
if (initToken.length() == 0) {
History.newItem(MAIN);
}
History.addValueChangeHandler(new ValueChangeHandler<String>() {
@Override
public void onValueChange(ValueChangeEvent<String> event) {
String token = event.getValue();
handleHistoryToken(token);
}
});
History.fireCurrentHistoryState();
RootPanel.get().add(mainPanel);
}
On Wednesday, October 17, 2012 2:25:49 PM UTC-4, Thomas Broyer wrote:
>
> The Right Way™ is to handle the token at application start. If you use
> History, then call History.fireCurrentHistoryState() from your
> onModuleStart; if you use places, call handleCurrentHistory() on your
> PlaceHistoryHandler.
> It's not only about "history" and the "back button", it's about making
> URLs to get you where you want/need within your app!
>
> On Wednesday, October 17, 2012 8:03:25 PM UTC+2, lexl wrote:
>>
>> Hi,
>>
>> I have a simple stateless app, with what I hope is a simple problem, but
>> I can't find an answer.
>>
>> On the main page is a button (Foo), when you click the button the history
>> is updated with a new token #foo, and the url becomes myapp.com#foo. So
>> far so good.
>>
>> When you hit refresh, GWT reloads the main page. No problem. However the
>> displayed url remains myapp.com#foo. and #foo continues to live in the
>> history stack, so that if I click the Foo button now, nothing happens. The
>> user stays on the main page.
>>
>> What's the right way to clear the history on a refresh or otherwise work
>> around this problem? The questions and answers I've seen have all talked
>> about synching server state, refreshing javascript state, etc. I don't have
>> any of those issues, I just need to clear the history or otherwise make the
>> button work, even if the token is already at the top of the history stack.
>>
>> thanks.
>>
>>
--
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/google-web-toolkit/-/oZS5HaoTSX8J.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-web-toolkit?hl=en.