You need to sign in to do that
Don't have an account?
phantom1982
Scope of variable in a Controller class
Can someone please explian the following?
Public Class AController{
Public AController(){}
Private boolean a = false;
Public firstupdatea{
this.a = true;
}
// this is called from the VF page in an action tag.
Public PageReference updatea(){
if (this.a == true){
// further actions..
}
}
}
Can someone please tell if the boolean a will retain the value (set to true) in the firstupdatea() function, when checked in the if condition in updatea()? if not? why and how can to make it work so it retains the value..
Thanks
Yes, value will be ratained, if you call firstupdatea() first and then make updatea() call.
Hope that helps.
Afzal
Thanks for replying. The function in the action tag runs after Constructor so the calling flow is ok.. but the value is not being retained.. any idea why??
Just wondering how the method is invoked from the VF Page. If it is invoking {! firstupdatea} (as a getter) , then the method should probably be called
Public void getFirstupdatea()
{
this.a = true;
}
Not to mention, that sometimes , the order in which Controller methods are invoked are somewhat unpredictable.