function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

I need to retain the values after refresh on visualforce page. can anyone help me to solve this issue?

When I Press the Save button it saves the values but when I hit F5 or refresh the values are gone, they are not visible on my VF page.
And for this :
  • I have created VF page with standard controller and extensions.
  • created one controller.
  • And I have embedded VF page into Opportunity object.
Any idea how I can achieve this ??
Tuur Dutoit 13Tuur Dutoit 13
I don't know if this would be possible in your case, but maybe pass them as parameters in the URL, like
Assuming they are values entered in input fields:
One possible way is to save them in the background periodically.
Another possiblity is using some javascript to save them on the user's computer every time they make a change:
sessionStorage.setItem("myField", valueFromInputField);
and retrieve them (using getItem()) when loading the page.
More info can be found here:

PS: Why would you need to refresh a page, but retain the values?
Are the entered values being stored in fields on your Opportunity record? If so, then perhaps when the Visualforce page is loaded, your Apex extension needs to locate the values and assign them to the appropriate class-level properties. This assumes you are exposing Apex properties from your Extension class as input fields in the VF page.

I believe that if you are referencing the Opportunity fields directly in the Visualforce (by referencing the Opportunity record in your Standard Controller), then you would see these values populated when the page loads.

Please share some examples from your code if you still need help with this.