0

I am creating a wizard using VF and I have a public variable public Id transferToUserId {get; set;} which is being set in step one.

However when I go to step two of my wizard, the variable is blank.

How can I make the value persist across my steps? Is there something I have to do in the controller, like

if (transferToUserId != null) {this.transferToUserId = transferToUserId}

1
  • When you redirect to the second page in the wizard, you need to set the redirect method as false. So that constructor of the page should not get executed. pg.setRedirect(false); Can you check, how this redirection is done in your code.
    – Devendra
    Aug 22, 2016 at 19:02

1 Answer 1

2

Assuming you are getting value for transferToUserId in constructor of the first page. To persist the values across same controller, you need to use the same controller for both vf pages. At the time of redirection, you need to use setRedirect(false) which will persist all the variables values as it is.

public class RedirectDemo{
    public Id transferToUserId  {get; set;}
    public RedirectDemo(){
        transferToUserId  = Apexpages.currentpage().getparameters().get('id');
    }

    public Pagereference redirectPage2(){
        Pagereference pg = new Pagereference('/apex/Page2');
        pg.setRedirect(false);
        return pg;
    }
}
1
  • Glad, It worked for you!
    – Devendra
    Aug 24, 2016 at 5:53

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.