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
babloo123babloo123 

Prevent reentering values in the VF page after submit

Can some one guide me how to prevent users from going back and entering details on VF page after clicking submit as submit function locks the page to edit further. But id he clicks back again the page opens need some guidance on this if any one has come across this issue?
mjohnson-TICmjohnson-TIC

Would need your sample code to know exactly what you are trying to accomplish.

Regardless, an initialize pagereference method may be your best route to go.

<apex:page controller="mycontroller" action="{!initialize}">
pagehere
</apex:page>

public with sharing class mycontroller{

public pagereference initialize(){
if(fieldvalue != null || variable != null){
pageference p = new pagereference('http://yoururlhere.com');
return p;
}else{
return null;
}
}
}

babloo123babloo123
Hi Johnson I am using a standard controller in my case on a custom object which has huge code around 800 lines but we have command button called submit which when clicked guides to another VF page called Thankyou. So after submit button he should not be able to go back but if now he clicks back then again the VF page is able to fill again or edit which should not happen can you just guide me here so instead of guiding to Thank you page you say me to guide to other page first and that other page redirects to thank you page? 

But I did not get field value and variable can you give me a small example. Your help is greatly appreciated
mjohnson-TICmjohnson-TIC
Sure. The submit button really needs to update a database value which can be evaluated on load of the Visualforce page. The action method gets evoked before the page loads. You said this form fills out fields on Case? I will try to give an example of this.


<apex:page standardcontroller="Case" extensions="mycontroller" action="{!initialize}">
<apex:inputfield value="{!Case.Subject}/>
<apex:commandbutton value="Submit" action="{!submit}"/>
</apex:page>

public with sharing class mycontroller{
Case c;

public ProjectController(ApexPages.StandardController controller) {
this.c = (Case)controller.getRecord();
}

public pagereference submit(){
c.Status = 'Closed';
update c;
return Page.Thankyou;
}

public pagereference initialize(){
if(c.Status = 'Closed'){
return Page.Thankyou;
}else{
return null;
}
}
}