Question 1
IntermediateUser Interface · Visualforce Controllers
A developer is tasked with creating a Visualforce page that displays a list of OpportunityLineItem records for a given Opportunity. The page must allow users to edit the Quantity and UnitPrice fields inline and save all changes with a single button click. The number of line items can exceed 100. Which controller approach is most suitable and efficient for this requirement?
Answer and explanation
Correct answer: C
A custom controller with a wrapper class is the most robust solution. The wrapper class can encapsulate the OpportunityLineItem sObject and any additional properties needed for the page, such as a boolean for row selection or temporary edit values. This approach provides maximum flexibility for handling complex page logic, especially for inline editing of multiple records, without being constrained by the features of standard controllers. The save method can then iterate through the list of wrappers, collect the modified records, and perform a single DML update, which is efficient.
