You need to sign in to do that
Don't have an account?
session scope
Hi there,
I have a series of Visualforce pages with forms that need to be filled out sequentially. Suppose on page 2 in this flow, I need access to a custom SObject that I just created on page 1. Except that I never actually stuck it in the DB with 'insert' on page 1, I just construted it.
In a Java web app, I'd put my instance from page 1 in the session and get at it from page 2. Is there any such thing in Salesforce?
If not, do I have to either put my custom SObject in the DB after page 1 (before I'd like to), just so I can get it out again on page 2? Or perhaps put a huge set of hidden form fields from page 1 on page 2 and have the controller populate these?
Thanks in advance.
Eliot Stock.
Or you can just create a wizard in Visualforce. If all of your pages use the same controller and you forward to them rather than redirect, all of your pages will share the same instance of the controller, therefore maintaining your state from page to page.
See this example in the dev guide.
All Answers
Or you can just create a wizard in Visualforce. If all of your pages use the same controller and you forward to them rather than redirect, all of your pages will share the same instance of the controller, therefore maintaining your state from page to page.
See this example in the dev guide.
Thanks! I was already doing exactly what the wizard example in the docs does, except that I was adding all these hidden fields to pages 2 onwards for stuff entered on earlier pages. I hadn't realised I don't need to do that.
How does it work? Does the server keep an instance of my controller alive in memory between requests or does the state get written to an internal hidden form field on the client for every page view? I think the latter.