Salesforce Certified Platform Developer II — Question 15
A company recently deployed a Visualforce page with a custom controller that has a data grid of information about Opportunities in the org. Users report that they receive a `Maximum view state size limit` error message under certain conditions.
According to Visualforce best practice, which three actions should the developer take to reduce the view state? (Choose three.)
Answer options
- A. Use the transient keyword in the Apex controller for variables that do not maintain state
- B. Use the final keyword in the controller for variables that will not change
- C. Use the private keyword in the controller for variables
- D. Refine any SOQL queries to return only data relevant to the page
- E. Use filters and pagination to reduce the amount of data
Correct answer: B, D, E
Explanation
Using the final keyword for immutable variables (B) prevents unnecessary changes that could increase the view state size. Refining SOQL queries (D) to fetch only relevant data reduces the amount of data stored in the view state, and implementing filters and pagination (E) further limits data displayed, ensuring optimal performance. The other options do not directly address reducing view state size effectively.