CRT-450 practice question 26 of 30
The value of the account type field is not being displayed correctly on the page. Assuming the custom controller is properly referenced on the Visualforce page, what should the developer do to correct the problem?
Full set: 201 questionsFor a Visualforce page to access and display a property from a custom controller, that property must be publicly accessible via a getter method. The Visualforce component framework uses these methods to read data from the controller. If the actType attribute is defined in the controller but lacks a public getter method (e.g., public String getActType() { ... } or is part of a public property with a {get;} accessor), the page cannot retrieve its value, resulting in it not being displayed.
1. Salesforce Developer Documentation
Apex Developer Guide
"Working with SOQL Queries": This section illustrates how controller properties are defined and used. It states
"To expose the results of a controller method to a page
the method must be public... For a page to be ableto use a property in a custom controller
the property needs a getter method." This directly supports option A.
Reference: Apex Developer Guide
Chapter 2: "Creating a Custom Controller"
Section: "Exposing Data to Visualforce Pages".
2. Salesforce Developer Documentation
Visualforce Developer Guide
"Custom Controllers and Controller Extensions": This guide explains the binding between Visualforce pages and Apex controllers. It details that expression language bindings like {!actType} resolve to getActType() or a public property actType with a get accessor. The absence of this getter prevents data retrieval.
Reference: Visualforce Developer Guide
Chapter 4: "Custom Controllers and Controller Extensions"
Section: "Creating a Custom Controller".
3. Salesforce Developer Documentation
Apex Developer Guide
"Using the with sharing
without sharing
and inherited sharing Keywords": This document clarifies that with sharing pertains to the enforcement of the organization's sharing model for record access
which is a different concern from property visibility for rendering on a page.
Reference: Apex Developer Guide
Chapter 6: "Security"
Section: "Using the with sharing
without sharing
and inherited sharing Keywords".
Keep practicing
Take the free CRT-450 practice test
Ten exam-style questions with answers and explanations, plus the exam facts and study guides.
More questions
Other CRT-450 practice questions
- Question 2A developer created a child Lightning web component nested inside a parent Lightning web …
- Question 4A developer needs to make a custom Lightning Web Component available in the Salesforce Cl…
- Question 6Given the following Apex statement: Account myAccount = [SELECT Id, Name FROM Account); W…
- Question 8Which action causes a before trigger to fire by default for Accounts?
- Question 9Universal Containers (UC) wants to lower its shipping cost while making the shipping proc…
- Question 10A custom picklist field, Pool Preference ¢, exists on a custom object. The picklist conta…
