Friday, September 14, 2018

viewstate in salesforce

Suppose we are having a requirement to register a user. If we are having multiple pages for user registration which user need to fill, so under this case we need to maintain the state when the user is moving from one page to other(i.e to maintain previous page data). By using form tag inside visualforce page we create view state. Governing limit for the view state is 135 kb. To avoid reaching the limit we should declare a variable as static or we need to mention transient keyword before the variable as this does not occupy the state. 

viewstate in salesforce



Solutions to reduce view state: 


1)Use remote method as it is stateless. 
2)Use transient keyword before variable which is not required to be retained as going forward to the next page. 
3)Avoid form tag if not required as it will not create view state. 

By reducing the view state the page load quicker so the performance of the page increases. 

**************************************************************************************************************

No comments:

Post a Comment