Take a look 
at: https://groups.google.com/d/topic/google-web-toolkit/OsDpLtBoTQo/discussion

I had nearly the same problem. Short version: If you have non singleton 
activities they will be restarted for every PlaceChangeEvent. If you want to 
avoid this you need to cache your Activity. But once you cache your activity 
if lives longer than its place it is started for. Thus the activity has to 
be notified once a PlaceChangeEvent occurs for the same place but with 
different internal state. This can be done by a method defined in every 
activity through a custom activity interface that extends Activity (e.g. 
setPlace() called by your activity caching code) or by letting the activity 
itself listen for PlaceChangeEvent and let the activity decide if it needs 
to update or not. That way you can always use placeController.goTo(new 
Place(new state)) to update the URL according to the current app state.

First I have used myActivity.setPlace() to notify the activity as I need 
this method anyways because of GIN. But that way you need an extra flag in 
your activity so you can decide if the activity is already running and you 
have to update it or if its not yet started and you can do the work once its 
started. So basically

public void setPlace(...) {
  //storing place information in activity variables
  //....
  //update activity/view
  if(isRunning) {
    doUpdate();
  }
}

public void start(...) {
  running = true;
  doUpdate();
}

So I prefer it to let the activity listen for PlaceChangeEvents. That way 
you won't need the extra boolean flag.

-- J.

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

Reply via email to