attempting to understand PlaceTokenizer<P>

217 views
Skip to first unread message

Thad

unread,
Mar 22, 2012, 1:04:52 PM3/22/12
to google-we...@googlegroups.com

I am trying to understand Places, PlaceTokenizer, and how and when to parse the token. I read about them, look at examples, watch there execution, and still I think I'm missing something. (The examples I follow seem not to fit me--they seem either trivial or too complex to follow.)


I have a Place, MyPlace. It may get a null token, or it may get a token with one or more items--state, id, etc. Examples would be "LIST" or "SHOW_ID;1234". I read from Thomas that "parsing should be done in a PlaceTokenizer" (https://groups.google.com/d/msg/google-web-toolkit/M5jCI-_95mQ/JJcClisInRoJ). However if when I do my parsing in MyPlace.Tokenizer.getToken(), the MyPlace that is passed to MyActivity contains the previous values for state and id. My trace looks like


instantiate MyPlace(LIST)

AppActivityMapper.getActivity(): com.foo.bar.client.place.MyPlace@be4139

instantiate MyActivity, place: com.foo.bar.client.place.MyPlace@be4139

starting MyActivity

MyView presenter set


It seems that the instantiation method for MyPlace must parse the token or calls to place.getState() and place.getId() will return values no yet set.


I can see MyPlace.Tokenizer.getToken() being called--though I'm not sure from where--but place.getState() does not return an updated value unless in start() wait with Scheduler.get().scheduleDeferred() and test the value in execute().


I never see MyPlace.Tokenizer.getPlace() called. What is it used for? *WHEN* is it used (never from what I see).


Currently I'm parsing the token in MyPlace's instantiation method, but it doesn't feel right.


Can anyone clarify this for me?

Thomas Broyer

unread,
Mar 24, 2012, 6:22:43 AM3/24/12
to google-we...@googlegroups.com

Thad

unread,
Mar 25, 2012, 10:49:17 AM3/25/12
to google-we...@googlegroups.com
Thanks, Thomas.  I had read this before, but it hadn't clicked with me.  I see now that MyPlace.Tokenizer.getPlace() is called on the back and forward arrows. 

After much re-reading, I believe that I've been over-thinking this. There doesn't seem to be any place in my current app where getToken() and getPlace() need to do anything more complex than acting on the token--just return or create a new place with it, no parsing, no rebuilding necessary. I'm trying to imagine doing something else, and I don't see it. 

However, I suppose it's possible to "fool" the history by altering the token such that the back button takes you somewhere else entirely. Is this correct?
Reply all
Reply to author
Forward
0 new messages