In an apex controller constructor I have set a value in a static variable (say VerificationCode). In the VFP button click action, I am invoking the registerUser method (non-static method), in the same method how can I access the VerificationCode static variable?

<apex:commandButton id="confBtn" action="{!registerUser}" value="Save and next"/>

Thanks in advance.

1 Answer 1


Your registerUser method can access the static variable ... statically.


public class YourControllerClassName
public static String verificationCode;

PageReference registerUser(){
  String code = YourControllerClassName.verificationCode;
  //more stuff...


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.