You need to sign in to do that
Don't have an account?
dfc
Controller Class Lifecycles
(1) Are VisualForce controller classes instantiated by the platform anew for multiple HTTP requests (of, say, the same page), or are they instantiated once for a user's entire session?
(2) If Page A uses controller class X, and Page B uses controller class X also, and a button on Page A performs logic and then navigates to Page B, is the same controller class instance of X used for both the "inbound" (from the user) Page A action and "outbound" (to the user) Page B rendering?
Thanks!
Dave
Hi dfc,
To answer your question:
1) Yes
2) What you've described here is a wizard behaviour. Please see my reply to Alan in this thread for more details.
- A J
All Answers
1. For Ajax requests, the state is saved. If you forward to another page, it will lose the controller state.
2. No, at least, I've never been able to carry state from one page to another using the same controller, without passing the info via URL params.
Hi paul,
It can be done if you are creating a wizard, which is basically one controller mapped to multiple visualfoce pages.
You can find a good example in the Visualforce Developers guide on Page 79.
I've copied a code snippet from the example described in the book.
// when users move from page to page.
public PageReference step1() {
return Page.opptyStep1;
}
public PageReference step2() {
return Page.opptyStep2;
}
public PageReference step3() {
return Page.opptyStep3;
}
- A J
Hi dfc,
To answer your question:
1) Yes
2) What you've described here is a wizard behaviour. Please see my reply to Alan in this thread for more details.
- A J