Friday, September 19, 2014

Re: Is there a tutorial that explains Places and Hyperlinks?

In general the hash fragment the GWT places framework generates consists of two parts: a unique prefix that represents the place type and a token that contains the serialized state of a place instance. Both are separated by a colon.

You can use @Prefix to change the default unique prefix of a Place which is the concrete Place class simple name, e.g. CustomerPlace.

To fill a Hyperlink target history token you would use the PlaceHistoryMapper.getToken(new CustomerPlace(<optional state>)) method which basically returns Prefix + ":" + tokenizer.getToken(place) .

If you don't like the colon you can also use your own logic by either implementing the PlaceHistoryMapper interface yourself or by creating just a single PlaceTokenizer<Place> with a prefix @Prefix(""). This tokenizer will act as a catch-all tokenizer and you can then freely implement your getToken() / getPlace() logic for all places inside that tokenizer. The catch-all tokenizer is kind of a cheat, so I would prefer implementing PlaceHistoryMapper directly. 
For example my apps usually use history tokens that look like /#!/archive/2014/august/

-- J.

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment