Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

page state is getting lost when back button is clicked

 
Ravi Goli
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I am having a problem getting my page state/history work with the Back button.

I have two jsp pages.
In the first page, I am dynamically building a select dropdown 'A' based and replacing the earlier select when an onclick event happens on the dropdown button. This I am doing by appending my built innerHtml to the Div element around the Select input.
There is a radio buttons-'B' section on my page. I am also modifying the text for a <TD> section on the page based on the 'B' radio buttons selection.

Now, I select a value from the dropdown-'A', and and do a page submit.
From the 2nd page, I click on the browser Back button.
Now in the first page, I do not see my initial changes done to the DOM preserved.
By initial changes, I mean:
The dynamically populated Select dropdown, and the
Modifying of the text for a <TD> section are getting lost.

The dropdown is getting set to the initial dropdown that I had loaded when the page is laoded for the first time
Or I can say the page is reloading for the caseof these elements.

Please, let me know how to preserve my dynamically populated state.

Thanks in advance for any reponses.

Ravi.
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Saving thee state is normally determined by the browser and you have no control over that.

You could store the values in a session cookie and look at the values on the page load event. If the values are there, you can set them through code.

Eric
 
Ravi Goli
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Eric for the response.

Right. Cookies is an option to get this work.

For Mozilla/Netscape history.next, history.previous, history[2], or so gives the location/url of the next/previous URLs.

Is there a similar way to access the URLs in the history object.

Thanks in advance.

Ravi.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic