How to resolve the View State Error ?
View State :
Visualforce pages that contain a form component also contain an encrypted, hidden form field that encapsulates the view state of the page. This view state is automatically created, and as its name suggests, it holds the state of the page - state that includes the components, field values, and controller state.
In Visualforce, page state is persisted as a hidden form field that is automatically inserted into a form when the page gets generated. We call this the view state of the page. The view state captures the state of the page -- state of its associated controllers and extensions and the component tree on the page. The view state is posted back along with the other form data, which gives the server enough information to recreate the page state to which new changes can be applied.
What is Contained in the View State:
The data in the view state should be sufficient to recreate the state of the page when the postback is received. To do this, it stores the following data:
a)All non-transient data members in the associated controller (either standard or custom) and the controller extensions.
b)Objects that are reachable from a non-transient data member in a controller or controller extension.
c)The component tree for that page, which represents the page's component structure and the associated state, which are the values applied to those components.
d)A small amount of data for Visualforce to do housekeeping.
View state data is encrypted and cannot be viewed with tools like Firebug. The view state inspector described below lets you look at the contents of the view state.
Best Practices for Optimizing View State:
a)Minimize Number of Forms on a Page
b)Declare Variables as Transient to Reduce View State
c)Recreate State versus Storing It in View State
d)Use Custom Objects or Custom Settings to Store Large Quantities of Read-Only Data
e)Refine Your SOQL to Retrieve Only the Data Needed by the Page
f)Refactor Your Pages to Make Its View Stateless
g)Consider Doing Your Own State Management in Certain Cases
Visualforce pages that contain a form component also contain an encrypted, hidden form field that encapsulates the view state of the page. This view state is automatically created, and as its name suggests, it holds the state of the page - state that includes the components, field values, and controller state.
In Visualforce, page state is persisted as a hidden form field that is automatically inserted into a form when the page gets generated. We call this the view state of the page. The view state captures the state of the page -- state of its associated controllers and extensions and the component tree on the page. The view state is posted back along with the other form data, which gives the server enough information to recreate the page state to which new changes can be applied.
What is Contained in the View State:
The data in the view state should be sufficient to recreate the state of the page when the postback is received. To do this, it stores the following data:
a)All non-transient data members in the associated controller (either standard or custom) and the controller extensions.
b)Objects that are reachable from a non-transient data member in a controller or controller extension.
c)The component tree for that page, which represents the page's component structure and the associated state, which are the values applied to those components.
d)A small amount of data for Visualforce to do housekeeping.
View state data is encrypted and cannot be viewed with tools like Firebug. The view state inspector described below lets you look at the contents of the view state.
Best Practices for Optimizing View State:
a)Minimize Number of Forms on a Page
b)Declare Variables as Transient to Reduce View State
c)Recreate State versus Storing It in View State
d)Use Custom Objects or Custom Settings to Store Large Quantities of Read-Only Data
e)Refine Your SOQL to Retrieve Only the Data Needed by the Page
f)Refactor Your Pages to Make Its View Stateless
g)Consider Doing Your Own State Management in Certain Cases
Comments
Post a Comment