Re: Correct methodology to update browser url with MVP
We are using the MVP pattern, and have a page with a selectable list. Each time an item is selected, we would like the URL to reflect the selection. Initially, the code used placeController.goTo() whenever an item was selected. However, we did not expect the activity's start() method to be called since its the same activity.Right now, that code is a bit heavier-weight (reloads the list) as I believe is expected to be the case with activities. Is there a way to refresh the URL without the activity being recalled, or is there a different way we should be going about this?
You can use GWT's FilteredActivityMapper to transform ItemPlace(<selected item>) into ItemPlace(<nothing selected>) and then use GWT's CachingActivityMapper to return the same activity if the place hasn't changed (determined by currentPlace.equals(newPlace), thats why you transform all ItemPlaces into equal ones using FilteredActivityMapper).
As the activity instance now lives longer the activity probably needs to listen for PlaceChangeEvent's, so you can select the correct item in the list if the user uses back/forward buttons of the browser. Activity.start() will only be called again if you navigate away from ItemPlace and then revisit it.
-- 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/groups/opt_out.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home