...and because an empty @Prefix is simply ignored when generating the token, you could have /#contactus that way.
I also have a Places / Token question and as this thread topic is a more general I post it here.First of all I do not like the default PrefixAndToken implementation and I would like to have place history tokens like the ones here in the new google groups app (#!place-name/group-name/thread-id). Is this possible with the default implementation of PlaceHistoryMapper or do I have to write my own one? As I can only have one Tokenizer with an empty Prefix I could also have only one "AppPlace" tied to that Tokenizer and so the getToken() / getPlace() methods of that Tokenizer would have to do all the magic to make thinks work. I think this would also mean that this one "AppPlace" needs to hold/know all other places so that they can store their state. Seems to me that this is not the nicest approach. Has someone already tried it?
How does Google do that here in Google Groups?
What I currently try is to implement a custom PlaceHistoryMapper that allows me to support Places that extend from other places to reuse their state. Imagine you have a CustomerPlace that stores the currently selected customer id. That CustomerPlace would also have an activity because you can switch between customers and for each switch some stuff has to be done, e.g. load picture, check privileges of the user to present tasks that the user is allowed to do for that customer. Lets say once the task list is loaded you are able to edit the customer so there would be a EditCustomerPlace. Now the EditCustomerPlace also have to store that customer id because if you jump to that place directly via its history token you need that information. How do you handle these situations without code things twice?
So my Idea is to be able to do something like EditCustomerPlace extends CustomerPlace and to generate the EditCustomerPlace history token by reusing the one from CustomerPlace.Example:CustomerPlace -> #/customer/1EditCustomerPlace -> #/editcustomer/<CustomerPlace state>/<additional EditCustomerPlace state> -> #/editcustomer/customer/1/addressI couldn't do that without a custom PlaceHistoryMapper, right? Or are there other/easier ways to reuse place states?
On Fri, Nov 25, 2011 at 3:38 PM, SurfMan <nlsu...@hotmail.com> wrote:
> Sorry to wake up an old thread, but after struggling with an empty
> place/token I ended up here too...
>
> I just don't understand why "#blah" would end up as the default place
> "" with token "blah", and why it's not place "blah" with an empty/null
> token. What is the reasoning behind this?
The serialization and deserialization processes have to be symmetric.
So if you allow an empty prefix and choose to serialize {prefix="",
token="foo"} as #foo (rather than #:foo), then you have to parse #foo
as {prefix="", token="foo"} (rather than {prefix="foo", token=""}).
The current choice is more flexible than the alternative, as it allows
the PlaceTokenizer for the empty prefix to create any kind of Place
depending on the token (if that's what you want), and falling back to
'null' for unknown tokens.
With the alternate design, the generated PlaceHistoryMapper would then
look for a PlaceTokenizer for the prefix "foo" and won't find any so
it'd fall back to the default place, always, without any hook for you
to customize this behavior).
--
Thomas Broyer
/tɔ.ma.bʁwa.je/