Plat-Dev-201 practice question 4 of 30

Universal Containers has a Visualforce page that displays a table of every Container__c being rented by a given Account. Recently this page is failing with a view state limit because some of the customers rent over 10,000 containers. What should a developer change about the Visualforce page to help with the page load errors?

Full set: 204 questions
Answer options
A: Implement pagination with an OffsetController.
B: Implement pagination with a StandardSetController. Correct answer
C: Use JavaScript remoting with SOQL Offset.
D: Use lazy loading and a transient List variable.
Correct Answer:
B. Implement pagination with a StandardSetController.
Explanation

The StandardSetController is a built-in Visualforce controller that is specifically designed to manage sets of records. It provides out-of-the-box functionality for pagination, such as next(), previous(), first(), and last() methods. By using a StandardSetController, the page will only load one page of records at a time into the view state, effectively resolving the "view state limit" error when dealing with thousands of records. This is the most direct and standard solution for this common Visualforce problem.

Why Incorrect

A. OffsetController is not a standard Salesforce class. While pagination is the correct approach, this is not the correct implementation class name.
C. JavaScript remoting avoids view state entirely but requires significant client-side code to build the table and manage state, making it more complex than the standard server-side solution.
D. A transient list variable is not stored in the view state, but it becomes null on postback, requiring it to be re-queried. It doesn't solve pagination on its own.

References

Salesforce Apex Developer Guide, "Using Standard Set Controllers," Section: "StandardSetController Class." This section details how StandardSetController enables pagination for displaying large record sets.

Salesforce Visualforce Developer Guide, "Best Practices for Improving Visualforce Performance," Section: "Minimize View State." This guide explicitly recommends using StandardSetController for pagination to manage large data volumes.

Scroll to Top