View State
In Salesforce Visualforce, the state data that is serialized and stored in a hidden form field on the page, preserving controller data between server requests so the page maintains its context during postbacks.
Definition
In Salesforce Visualforce, the state data that is serialized and stored in a hidden form field on the page, preserving controller data between server requests so the page maintains its context during postbacks.
In plain English
“View State in Salesforce Visualforce is the state data serialized and stored in a hidden form field on the page. It preserves controller data between server requests so the page maintains context during postbacks. Large view states cause performance issues.”
Worked example
A Visualforce page at Easterton Software with a complex form maintains its server-side controller state via View State - a hidden form field on the page containing the serialized controller properties. When the user submits the form, the View State travels back to the server, the controller deserializes it, processes the input, and re-renders the page. Large View States (over 135 KB by default) cause performance issues and governor-limit errors; the developer trims unused properties from the controller to keep View State small. View State is a Visualforce-specific concept; Lightning components handle state differently (component state, Apex calls).
Why View State matters
In Salesforce Visualforce, View State is the state data that is serialized and stored in a hidden form field on the page, preserving controller data between server requests so the page maintains context during postbacks. The view state has a 170KB limit.
View state management is one of the trickiest Visualforce performance challenges. Large view states slow page loads because all the data must be serialized, sent to the browser, and sent back on every postback. Mature Visualforce developers minimize view state by using transient variables for data that doesn't need to persist.
How organizations use View State
Teaches view state optimization as critical Visualforce performance skill.
Uses transient variables to minimize view state in complex Visualforce pages.
Monitors view state size as part of Visualforce performance management.
Trust & references
Straight from the source - Salesforce's reference material on View State.
- Visualforce View StateSalesforce Developers
Test your knowledge
Q1. What is View State?
Q2. What's the size limit?
Q3. How do you reduce view state?
Discussion
Loading discussion…