View Full Version : MVC, view state, and browser Back/Forward/Refresh buttons

29 Apr 2011, 4:35 AM
Really like the MVC pattern and have recently implemented the MVC pattern to use the historyUrl with all dispatch commands so we can use the browser back/forward buttons within the app.

This works great, however, it opens up another bag of worms in how we should be passing parameters from the the dispatch call, to the controller actions, and on to the view that the action instantiates. The back and forward buttons work fine, but I noticed that when the refresh button is pressed, the view's initComponent is fired again but the params that were passed from the action into the view via the config object are not present on the refresh:

Action's call to instatiate view:

// Display a list of products
list: function (options) {
view = new mynamespace.ViewProductList({
// define view options
param1: options.paramFromDispatch1,
param2: options.paramFromDispatch2

Should I be looking to pass the params in another way, like constructing a querystring and appending to the historyUrl? If so, how do I get access to these params in the action and the view?

Seems like you might have to do both, construct a QS with enough params for the page to rebuild itself, and use the options and config objects to pass additional params or object variables.

In the end, I am just looking to handle the refresh button in a graceful way and looking to see what others are doing for this. Better to try to reinitialize the whole app upon browser refresh?

Thanks for any input.