+ Start a Discussion
Lavi__cLavi__c 

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 ??
Thanks.
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
https://myInstance.salesforce.com/apex/MyVisualforcePage?myField=someValue
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: https://developer.mozilla.org/en/docs/Web/API/Window/sessionStorage

PS: Why would you need to refresh a page, but retain the values?
pigginsbpigginsb
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.