While viewers of the Spring ’12 Preview Webinar saw the new single view state in action, I thought it best to give a overview here on the blogs for people to read as well.

If you are a Visualforce developer and you aren’t familiar with the concept of a viewstate, it is one worth getting your head around as you try to make your pages as performant as possible.  As HTTP is a stateless format, the viewstate is a section of data, represented as a long hashed string, on your Visualforce pages which allows Visualforce to maintain the state between the client and the server.  Perform a rerender?  The viewstate keeps things in check.  Posting back information to Apex?  The viewstate is making sure the values being bound are kept straight.  Developers who have used JavaScript Remoting know that the fundamental difference between using actionFunctions and Remoting is that with Remoting there is no viewstate and maintaining state is up to JavaScript and the developer.

A long standing best practice for Visualforce developers has been to keep the number of Apex form tags to a minimum – preferably only one.  The reason for this is that multiple form components results in multiple viewstates which in turn add bloat and complexity to the pages.  With Single View State, which will be a pilot with Spring ’12 requiring Salesforce to enable, multiple form components will have their viewstate reduced down to a single one.  This feature, once enabled, will require no additional coding or setup – it’s not an attribute on the page or form component or anything like that … it is simply a performance gain for Visualforce in general.

I would still recommend developers think and test how they define their forms, however.  There may be instances where placing forms in components now becomes more desirable because it will not result in a performance drop.  There may also be existing limitations, like placing form components within a repeater component – where the outcome might not work as expected.

Spring ’12 is looking to be an excellent evolution of the platform and I’ll be interested to see as this pilot rolls out if we’ll see a sudden performance increase for existing implementations.  Keep an eye out on trust.salesforce.com for when Spring ’12 will hit an instance near you, the release portal and this blog for more information.  As usual, you can comment below or catch me on twitter @joshbirk.

Get the latest Salesforce Developer blog posts and podcast episodes via Slack or RSS.

Add to Slack Subscribe to RSS