You need to sign in to do that
Don't have an account?
tarun.khandelwal1.3965028573349685E12
Abrupt Behavior with Browser back and Ajax Call
Hello All,
I am using command button to perform an ajax call.
Please find the code snippet below
Controller:
public with sharing class TestController { public TestController(){ this.flag=true; ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.Info,'Loading Constructor : '+String.valueOf(flag))); } public PageReference changeFlagValue(){ ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.Info,'Value Before Change : '+String.valueOf(flag))); if(flag){ flag=false; } else{ flag=true; } ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.Info,'Value After Change : '+String.valueOf(flag))); return null; } public PageReference displayFlagValue(){ ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.Info,'Current Value : '+String.valueOf(flag))); return null; } public Boolean flag{get;set;} }VF:
<apex:page showheader="false" sidebar="false" controller="TestController"> <apex:form > <apex:commandButton action="{!displayFlagValue}" value="Display" rerender="pageMessages" /> <apex:commandButton action="{!changeFlagValue}" value="Change" rerender="pageMessages" /> <a href="http://google.com">Move</a> </apex:form> <apex:pageMessages id="pageMessages" /> </apex:page>
Command Button : Changes the value of Flag.
Constructor : Reinitializes the flag value to true.
Steps :
1. Load the Page.
2. Press Display : Shows true
3. Press Change : Shows false
4. Click on Move :
5. Press Browser Back Button.
6. Constructor Loaded : Value Reset To True
7. Press Display :
Ajax call using last value before moving to Google Page, But in controller flag value is changed.
Can any please tell me the logic behind this behavior.
Thanks
I tried this code in my developer org. When I move to google and press back, and then click Display, I see:
Current Value : true
which lookslike expected. Can you let me know if your question/issue is different?
Thanks,
Shashank