PDI · Question #199
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…
The correct answer is B. Implement pagination with a StandardSetController. To resolve a Visualforce view state limit error caused by displaying over 10,000 records, the developer should implement pagination using a StandardSetController.
Question
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?
Options
- AUse JavaScript remotlng with SOQL Offset.
- BImplement pagination with a StandardSetController.
- CImplement pagination with an OffaetController.
- DUse lazy loading and a transient List variable.
How the community answered
(36 responses)- A3% (1)
- B94% (34)
- C3% (1)
Why each option
To resolve a Visualforce view state limit error caused by displaying over 10,000 records, the developer should implement pagination using a `StandardSetController`.
While JavaScript remoting can fetch data asynchronously, using SOQL `OFFSET` for pagination with very large data sets (like 10,000+ records) is generally inefficient and can lead to performance degradation as the offset increases.
Implementing pagination with a `StandardSetController` is the most effective and recommended solution for handling large data sets on Visualforce pages. This controller automatically limits the number of records displayed per page, significantly reducing the view state size and improving page performance by only fetching a subset of records at a time.
`OffsetController` is not a standard Salesforce class or pattern available for Visualforce pagination; `StandardSetController` is the correct class for this purpose.
Using the `transient` keyword for a list variable can reduce view state by preventing its serialization, but it does not address the fundamental problem of initially querying and processing an excessively large number of records from the database, which pagination handles.
Concept tested: Visualforce pagination with StandardSetController
Source: https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_controller_sosc_pagination.htm
Topics
Community Discussion
No community discussion yet for this question.