PDI · Question #218
Consider the following code snippet for a Visualforce page that is launched using a Custom Button on the Account detail page layout. When the Save button is pressed the developer must perform a…
The correct answer is B. Controller extension. A controller extension is the most appropriate solution as it allows for adding custom business logic, such as complex multi-object validations and custom redirects, while still leveraging the standard controller's functionality for a Visualforce page.
Question
Consider the following code snippet for a Visualforce page that is launched using a Custom Button on the Account detail page layout. When the Save button is pressed the developer must perform a complex validation that involves multiple objects and, upon success, redirect the user to another Visualforce page. What can the developer use to meet this business requirement?
Exhibit
Options
- ACustom controller
- BController extension
- CValidation rule
- DApex trigger
How the community answered
(24 responses)- A4% (1)
- B71% (17)
- C17% (4)
- D8% (2)
Why each option
A controller extension is the most appropriate solution as it allows for adding custom business logic, such as complex multi-object validations and custom redirects, while still leveraging the standard controller's functionality for a Visualforce page.
A custom controller completely replaces the standard controller, meaning the developer would have to reimplement all standard save/cancel behavior, which is usually more work than extending existing functionality.
A controller extension allows a developer to augment the functionality of a standard or custom controller without replacing it, enabling the addition of complex validation logic involving multiple objects and custom navigation or redirection upon successful processing, directly from the Visualforce page's save action.
Validation rules provide declarative validation for single objects and cannot handle complex multi-object validation or custom redirection logic directly from a Visualforce page's controller action.
An Apex trigger executes automatically before or after DML operations on records; it is designed for backend data manipulation and validation, not for controlling Visualforce page flow, complex multi-object validation directly tied to a page's save action, or page redirection.
Concept tested: Visualforce controller extensions
Source: https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_controller_extensions.htm
Topics
Community Discussion
No community discussion yet for this question.
