I have a button that updates an opportunity. When it is complete the page refreshes but doesn't reload with updated data here is my code:
Controller
public class ContractDetails{
public Opportunity ThisOpportunity{get;set;}
public string oppid {get;set;}
public string requested {get;set;}
public ContractDetails(){
oppid = ApexPages.currentPage().getParameters().get('id');
requested = ApexPages.currentPage().getParameters().get('requested');
string selected = 'background-color:#4bca81;color:white';
if(oppid==null){
oppid = ApexPages.currentPage().getParameters().get('oppidd');
}
ThisOpportunity = [Select Contract_Requested__c FROM Opportunity where ID=:oppid];
if(ThisOpportunity.Contract_Requested__c == boolean.valueOf('true')){
requested = selected;
}
}
public void save(){
ThisOpportunity.Contract_Requested__c = boolean.valueOf('True');
system.debug(ThisOpportunity.Contract_Requested__c);
update ThisOpportunity;
}
VFP:
<apex:page controller="ContractDetails" showHeader="false" standardStylesheets="false" sidebar="false" docType="html-5.0" >
<html xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<apex:slds />
<script type="text/javascript">
function requested(){
requestedoper();
}
function rerender(){
window.location.href='/apex/TestPage?oppidd={!oppid}';
}
</script>
<apex:form id="wf">
<button class="slds-badge" style="{!requested}" onclick="requested()">Requested
<apex:actionfunction action="{!save}" name="requesteoper" oncomplete="rerender()"></apex:actionfunction></button></apex:form>
</html>
</apex:page>
I would expect the {!requested} to be loaded with the selected variable on the reload, but it appears it doesn't rerun the sobject query in the main function.
How do I get this to rerun?
The page refreshes then runs the method in the controller in a separate operation, see log below: