You need to sign in to do that
Don't have an account?
Abhik Dey
Oncomplete issues with apex commandButton
Folks.
I am using <apex:commandButton value="Next" action="{!method1}" rerender="test" oncomplete="complete1();"/>
Once the method1 executes, it updates a boolean variable to 'true' and in the constructor this variable value is set as false
public void method1(){
fieldstatus='true';
//system.debug('fieldstatus:'+fieldstatus);
}
Now on VF page , i want to access this variable value so used oncomplete, but in the oncomplete function i always got the value as false.
function complete1() {
var check1= '{!fieldstatus}';
alert(check1);
}
Any idea why this wierd behaviour?
I am using <apex:commandButton value="Next" action="{!method1}" rerender="test" oncomplete="complete1();"/>
Once the method1 executes, it updates a boolean variable to 'true' and in the constructor this variable value is set as false
public void method1(){
fieldstatus='true';
//system.debug('fieldstatus:'+fieldstatus);
}
Now on VF page , i want to access this variable value so used oncomplete, but in the oncomplete function i always got the value as false.
function complete1() {
var check1= '{!fieldstatus}';
alert(check1);
}
Any idea why this wierd behaviour?
Controller:-
public class Apex{
public boolean test{get;set;}
public Apex(){
test = false;
}
public void method1(){
test = true;
}
}
Page:-
<apex:page showHeader="false" controller="Apex">
<apex:outputPanel id="tst">
<script>
function complete1() {
var check1= '{!test}';
alert(check1);
}
</script>
<apex:form>
<apex:commandButton value="Next" action="{!method1}" rerender="tst" oncomplete="complete1();"/>
</apex:form>
</apex:outputPanel>
</apex:page>
Mark as answer if it helps you.
All Answers
Controller:-
public class Apex{
public boolean test{get;set;}
public Apex(){
test = false;
}
public void method1(){
test = true;
}
}
Page:-
<apex:page showHeader="false" controller="Apex">
<apex:outputPanel id="tst">
<script>
function complete1() {
var check1= '{!test}';
alert(check1);
}
</script>
<apex:form>
<apex:commandButton value="Next" action="{!method1}" rerender="tst" oncomplete="complete1();"/>
</apex:form>
</apex:outputPanel>
</apex:page>
Mark as answer if it helps you.