Universal Containers has a Visualforce page that displays a table of every Container_c. being ……. Is falling 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?
A. Use Lazy loading and a transient List variable.
B. Use JavaScript remoting with SOQL Offset.
C. Implement pagination with an OffsetController.
D. Implement pagination with a StandardSetController,
D. Implement pagination with a StandardSetController,
Explanation:
When a Visualforce page displays large datasets, such as 10,000+ Container__c records, it risks hitting View State limits due to excessive data being stored in the page’s state.
StandardSetController helps by:
Providing built-in pagination and limits the number of records loaded at once.
Reducing the View State size, since it only keeps a small batch of data in memory.
Easily integrating with Visualforce table components.
This is the recommended and scalable approach for large data sets in Visualforce pages.
Why the Other Options Are Incorrect:
A. Use Lazy loading and a transient List variable
Lazy loading and transient variables help in Apex controllers but do not solve view state problems directly unless combined with proper pagination.
Still requires custom logic for data batching and doesn't scale well without pagination.
B. Use JavaScript remoting with SOQL Offset
JavaScript remoting avoids view state but SOQL OFFSET is limited to 2,000 rows and can impact performance. Not viable for 10,000+ records.
Also adds complexity and moves logic to the client side.
C. Implement pagination with an OffsetController
Requires custom pagination logic.
OFFSET in SOQL has performance limitations and is not efficient for large datasets beyond 2,000 records.