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
UjwalaUjwala 

Avoid resubmission on refresh of VF

Hi,

in my VF i am insert record in account on click of button.. but after clicking save button it creates record in database but at this stage only when i refresh page(F5 .. using chrome) again record is inserted in database.. I think it is happening because of browser warning "The page that you're looking for used information that you entered. Returning to that page might cause any action you took to be repeated. Do you want to continue?" when click refresh..

can anybody please suggest way forward to this condition.. 
Best Answer chosen by Ujwala
Sohan Raj GuptaSohan Raj Gupta
Hi Ujwala,

I think you are using Void as return type in your method. So you should change it by PageReference and set return URL is same.

Hope this will help you. Let me know if it helped or you need any more assistance. 

Please mark this is as the solution if it solved your purpose.

Thanks,
Sohan Raj Gupta 

All Answers

Sohan Raj GuptaSohan Raj Gupta
Hi Ujwala,

I think you are using Void as return type in your method. So you should change it by PageReference and set return URL is same.

Hope this will help you. Let me know if it helped or you need any more assistance. 

Please mark this is as the solution if it solved your purpose.

Thanks,
Sohan Raj Gupta 
This was selected as the best answer
UjwalaUjwala
Thank you  Sohan Raj Gupta for your reply..
yes it is working but every time i click save button whole page is reloading.. before this I was rerendering particular block on click of save. and one more thing..my page has validations from apex using addError method.. when there is error my page is not showing error .. when there is error immediatly page gets reloaded after adding pagereference.. 
Sohan Raj GuptaSohan Raj Gupta
Hi Ujwala,

If you are preforming any validation using APEX then you can retrun null in this case. So your error message will show on page.

You can also save your information using ActionFunction OR ActionSupport. By using that you can render particluar block also.

Regards,
Sohan Raj Gupta
UjwalaUjwala
Hi,
return  null raises same resubmission problem..
So i am redirecting using id of record.

Thanks for your help