Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am following the book Visualforce Developer's Guide. There is one thing I am not quite clear with: when multiple VF pages are using one single controller - like in a wizard, how do VF decide when to create a new controller class instance and when will it use a previous one?

share|improve this question
up vote 7 down vote accepted

According to visualforce guide > pageReference > setRedirect

If setRedirect(false), the redirect is a server-side forward that preserves the view state if and only if the target page uses the same controller and contains the proper subset of extensions used by the source page.

In other words, if you want the controller to be reinstantiated (and hence the constructor reinvoked), in the pageReference method, use pgRef.setRedirect(true). The next page is loaded with the whole controller reinstantiated via its constructor.

But, if you don't want the controller class to be reinstantiated, use pgRef.setRedirect(false). the next page is loaded without re-construction.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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