Thursday, January 27, 2011

Re: Simple history question



On Thursday, January 27, 2011 5:32:52 PM UTC+1, Navigateur wrote:
Before I delve, what's the most elegant way of handling the start page
of your app? (i.e. going back to it?)

Really my question is about the fact that for e.g. "page2" you have
created a history token with the String "#page2"... but when you press
the "back" button after this, you go back to the first page that
has... no token? So how do you test for this?

Sorry if this sounds stupid (and I haven't done it yet)... but does
the ValueChangeHandler just give you a token with an empty String ("")
when you do this?

Yes.
 
If not, what's the most elegant way of including the first page in
your history, without repeating any code, and without adding
unnecessary items in the browser history?

The easiest way is to start your ValueChangeHandler with code like:
  if (historyToken.isEmpty()) {
    historyToken = DEFAULT_TOKEN;
  }
 
or to only ever associate that "default page" with the empty token.

This is similar to whether you'd link to "/index.html" (default name used by your web server when asked for "/") or "/" (and never ever use "index.html" in your links).

I'd highly suggest you to use GWT 2.1 Places though!

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

No comments:

Post a Comment