Changing the Place History without really going to a place

26 views
Skip to first unread message

P.G.Taboada

unread,
Jul 19, 2011, 8:13:24 PM7/19/11
to Google Web Toolkit
Hi,

I need to tell the history manager that I am switching from
userViewPlace: to userViewPlace:someToken. I do not need to really
switch the place, but I need the history to change.

The following does the trick, but it feels like cheating.

History.newItem("SomePlace:" + new
SomePlace.Tokenizer().getToken(new SomePlace(infosNeeded)), false);


Any better solution?

brgds,

Papick

ashwin....@gmail.com

unread,
Jul 19, 2011, 9:46:54 PM7/19/11
to google-we...@googlegroups.com
best would be to do a place change, call the same activity, but re-use the view (you can mark it singleton). this would make the code clean. 


--
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-we...@googlegroups.com.
To unsubscribe from this group, send email to google-web-tool...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.


tanteanni

unread,
Jul 20, 2011, 1:55:35 AM7/20/11
to google-we...@googlegroups.com
Ashwin is right,

use MVP Pattern (you could easily ignore ui binder stuff). The "activity" will become the (P)resenter. Make it listen to placeChangeEvents . OnPlaceChange-method extracts the token from the place . Set up / change the view (MVP say that views should be singletons). so your view interface probably has some updateView(partOfToken) method.
To do the same on construction time (if first call of activity is with token - a bookmarked link) u have to give the place the constructor (if u use gin(dependency injection framework) its better to give the place controller) and extract the token in start() method.

Now only one problem persists: i guess in your activity mapper there is code like this
(if place instanceof userViewPlace) return new userViewActivity ?!

To reuse the old activity (that's the "without really going to a place"): return an activity saved in a field in activityMapper like this:

private userViewActivity;

....
if(userViewActivity==null)
...userViewActivity=new ...activity..
else
return userViewActivity;

(you could also try the hard way (but "official") to cache the activity: LayoutMVP example - good example to learn also MVP)
Reply all
Reply to author
Forward
0 new messages