User Interface Ob1 Flashcards
A developer needs to retrieve certain records and load them in a table on a Visualforce page. The developer would like to be able to customize the look and feel of the table and not use standard Salesforce styling.
What Visualforce components can the developer use?
A. <apex:dataList>, <apex:listTable>, or <apex:table>
B. <apex:dataTable>, <apex:dataList>, or <apex:repeat>
C. <apex:pageBlockTable>, <apex:dataTable>, or <apex:dataList>
D. <apex:table>, <apex:listTable>, or <apex:pageBlockTable>
B. <apex:dataTable>, <apex:dataList>, or <apex:repeat>
The <apex:dataTable>, <apex:dataList>, and <apex:repeat>
Visualforce components can be used to create tables with custom styles.
The <apex:pageBlockTable>
component can be used to build a table but comes with default Salesforce styling. A Visualforce component called <apex:table>
or <apex:listTable>
does not exist.
Display Records, Fields, and Tables
🧠 Explanation:
If a developer wants full control over styling (i.e. not use standard Salesforce CSS or styling), the best components to use are:
<apex:dataTable> – renders a table and allows full CSS styling.
<apex:dataList> – similar to a data table but rendered as an HTML list.
<apex:repeat> – extremely flexible, lets you repeat any markup (including divs, tables, etc.) and apply custom styles freely.
❌ Why the other options are wrong:
A and D: <apex:listTable>, <apex:table> are not valid Visualforce components.
C: <apex:pageBlockTable> uses standard Salesforce styling, which goes against the requirement.
</apex:pageBlockTable></apex:table></apex:listTable></apex:repeat></apex:dataList></apex:dataTable>
The sales representatives of Cosmic Lights use a Visualforce page in Salesforce to search for and view billing information related to account records. A custom object named Billing__c is used for this.
The page currently uses a standard controller.
Now, the company wants sales reps to click a button on that page to:
Retrieve billing info from an external system via REST callout, and
Update the Salesforce record accordingly.
A. Use a custom controller in order to perform all the required operations and execute REST-based callouts to the external system.
B. Edit the standard controller of the Visualforce page and add the code to execute a REST-based callout to the external system.
C. Replace the standard controller with a controller extension to perform all required operations and REST-based callouts to the external system.
D. Use the standard callout action of the standard controller in order to execute a REST-based callout to the external system.
✅ Correct Answer: A.
🧠 Explanation:
Standard controllers in Visualforce are great for basic CRUD operations. However:
They cannot execute REST callouts.
They cannot include custom logic like calling external APIs.
To perform a REST-based callout and update Salesforce data, the developer must:
Create a custom controller class.
Define a method that performs the callout.
Add logic to update the Billing__c record with the response.
➡️ This gives full control over the backend behavior.
A developer is building an Apex controller for a Visualforce page and wants to ensure that the heap size is minimized to avoid performance issues.
Which of the following practices can help keep the heap size low?
A. Use Limit methods to extend the governor limits on memory usage.
B. Use a SOQL for loop for processing results returned by a query.
C. Use the ‘transient’ keyword with variables when declaring them.
D. Store all results of a SOQL query in a variable first before iterating.
B. Use a SOQL for loop for processing results returned by a query.
C. Use the ‘transient’ keyword with variables when declaring them.
Using the ‘transient’ keyword prevents an instance variable from being transmitted as part of the view state of a Visualforce page. SOQL for-loops use efficient chunking to reduce the heap size. Saving all results of a SOQL query in a variable at once causes all data to be placed in memory instead of it being retrieved in chunks as needed. Limit methods are used to monitor/manage the heap during execution and not to reduce the total amount of memory used. For example, Limits.getLimitHeapSize() returns the total amount of memory (in bytes) that can be used for the heap in the current context.
If a developer is required to create a page that allows performing standard actions on multiple records, what controller can accomplish this with the least effort?
A. Custom Controller
B. Standard List Controller
C. Standard Controller
D. Lightning Bundle Controller
B. Standard List Controller
🧠 Explanation:
The Standard List Controller is specifically designed to handle multiple records of a given object in Visualforce pages. It comes prebuilt with standard functionality like:
- View
- Edit
- Delete
- Pagination
- Sorting
All this without having to write custom Apex code. That makes it the most efficient choice when your goal is to act on a list of records with minimal development effort.
Associating a Standard List Controller with a Visualforce Page
What attribute should the developer use to render a Visualforce page as a PDF file?
A. renderAs=”pdf”
B. docType=”pdf-5.0”
C. contentType=”application/vnd.pdf”
D. docType=”pdf-1.0-strict”
✅ Correct Answer: A.
A developer can generate a downloadable, printable PDF file of a Visualforce page using the PDF rendering service. A Visualforce page rendered as a PDF file displays either in the browser or is downloaded, depending on the browser’s settings. Specific behavior depends on the browser, version, and user settings, and is outside the control of Visualforce.
Which iteration components can be used to display a table of data on a Visualforce page?
A. <apex:outputTable> and <apex:pageBlockTable>
B. <apex:table> and <apex:outputTable>
C. <apex:dataTable> and <apex:table>
D. <apex:pageBlockTable> and <apex:dataTable>
D. <apex:pageBlockTable> and <apex:dataTable>
Iteration components work on a collection of items instead of a single value. <apex:pageBlockTable>
is a type of iteration component that can be used to generate a table of data, complete with platform styling. The <apex:dataTable>
component can be used if custom styling is required.
A developer is required to build a Visualforce page that allows a user to upload an attachment for a record. In the upload form, Attachment fields such as Name and Description must be populated by the user, as well as certain additional fields that will be saved to the parent record.
A. Standard List Controller
B. Custom Controller
C. Standard Controller
D. Custom List Controller
B. Custom Controller
🧠 Explanation:
To build a Visualforce page that:
Allows uploading attachments,
Populates fields like Name and Description,
AND updates additional fields on the parent record,
…the developer needs full control over the form logic, file handling, and saving process. That level of customization requires a Custom Controller.
With a Custom Controller, you can:
Manually manage the file upload using Attachment.Body or ContentVersion.VersionData
Set all fields programmatically
Handle saving the parent record and the attachment in one transaction
Using the sample controller class below, what is the value of the count variable when the following line is run?
MyController c = new MyController(); Integer x = c.count;
Code:
public class MyController { public Integer count { get { if (count == null) { System.debug('get count'); count = 10; } else { System.debug('increment count'); count++; } return count; } private set; } public MyController() { System.debug('constructor begins'); if (count == null) { count = 20; } System.debug('constructor ends'); } public void logCount() { System.debug('The value of count is: ' + count); } }
A. 10
B. 21
C. 11
D. 20
C. 11
In the constructor, when the “if statement” reads the count variable, the get property of the variable is called before the conditional block starts the evaluation. In the get property, count will have been null so its value will be set to 10 and returned.
The value is then received back into the “if statement”, and since count has been set to 10 at this point, it will not satisfy the condition during the evaluation. When the count variable is referenced in the logCount method, the get property is called again, but this time the value will be incremented since it no longer contains a null value.
A developer is creating a customized page in which the standard record detail page of an object is included.
A. <apex:detail>
B. <apex:dataList>
C. <apex:record>
D. <apex:recordPage></apex:recordPage></apex:record></apex:dataList></apex:detail>
✅ Correct Answer: A.
🧠 Explanation:
The <apex:detail> component is used when you want to display the standard Salesforce detail page layout for a record inside a Visualforce page.</apex:detail>
It’s the easiest way to embed the default layout (fields, sections, related lists) that a user would normally see when viewing a record.
<apex:page standardController="Account"> <apex:detail relatedList="true" title="true"/> </apex:page>
This displays:
The record detail section
The related lists (if relatedList=”true”)
The standard page title (if title=”true”)
❌ Why the others are incorrect:
B. <apex:dataList> → Used to display a list of records, not a detail page.</apex:dataList>
C. <apex:record> → ❌ No such component in Visualforce.</apex:record>
D. <apex:recordPage> → ❌ Not a valid Visualforce tag.</apex:recordPage>
A developer is creating a custom controller which will contain a web service method.
Which access modifier must be used to declare the class?
A. public
B. private
C. global
D. protected
C. global
🧠 Explanation:
En Apex, si vas a definir un método con la palabra clave webService, necesitas que la clase también sea accesible desde fuera del sistema Salesforce, como desde una integración externa.
Para eso, se necesita que la clase sea global.
📌 Esto es lo que debes tener en cuenta:
webService methods deben estar en una clase con el modificador global.
public no es suficiente si el método será usado desde fuera de Salesforce.
Apex classes containing web service methods must be defined as global, which will allow the class to be used anywhere in the org, including Apex code that belongs to other packages.
The private access modifier cannot be used on top-level classes. The public access modifier makes a class accessible to Apex code within the same package. The protected access modifier can only be used on class methods.
Considerations for Creating Custom Controllers and Controller Extensions
A developer at Cosmic Solutions needs to create a Visualforce page to display Case records in a table and is considering to use a standard list controller so that building a custom controller is not necessary.
Which of the following is a valid consideration when using standard list controllers?
A. A dynamic number of records can be loaded on the page
B. Records can be dynamically sorted by rendered fields
C. A controller extension must be used for record pagination
D. Existing list view filters cannot be applied to the records
✅ Correct Answer: A.
🧠 Explanation:
The Standard List Controller in Visualforce is used to work with a collection of records (e.g., a list of Cases). It provides built-in support for:
Pagination
Sorting (based on list views)
Filtering via standard list view filters
Loading a configurable number of records per page (like 10, 25, 50, etc.)
📌 So A is correct because you can control how many records to display by using standard pagination features like:
A developer is required to create a Visualforce page that displays data from a web service callout.
Which of the following options, on its own, can meet this requirement?
Choose 1 answer.
A. Controller Extension
B. Custom Controller
C. Standard List Controller
D. Standard Controller
B. Custom Controller
🧠 Explanation:
Cuando quieres hacer un web service callout (como llamar a una API externa desde Apex), necesitas tener acceso total a la lógica Apex para:
Definir el método que hace el callout (Http, HttpRequest, etc.)
Manejar los datos que vienen de la respuesta
Controlar cómo se muestran en la página
👉 Esto no se puede hacer con un Standard Controller ni con un Standard List Controller, ya que esos no permiten lógica personalizada como callouts.
A Salesforce developer needs to execute custom logic on records that users select in a related list.
Which method of the StandardSetController class can be used to return the records selected by a user?
Choose 1 answer.
A. getChecked()
B. getCheckedList()
C. getSelected()
D. getSelection()
C. getSelected()
The getSelected() method returns a list of sObjects representing the selected records.
A developer has a requirement to display a chart on the Account page layout to help users visualize data.
Which of the following statements is true about using charts on a Visualforce page?
A. Visualforce charts can be displayed in a Visualforce page rendered as PDF
B. Third-party JavaScript charting libraries are not supported on a Visualforce page
C. Visualforce charts can be used for visualizing report data in Report Builder
D. A collection of standard components can be used to create Visualforce charts
✅ Correct Answer: D.
A collection of standard components can be used to create Visualforce charts``
🧠 Explanation:
Salesforce ofrece una serie de componentes estándar de Visualforce como:
<apex:chart>
<apex:pieSeries>
<apex:barSeries>
<apex:lineSeries>
Estos componentes permiten crear gráficos directamente en Visualforce, sin necesidad de JavaScript adicional.
Con ellos puedes visualizar datos de objetos de Salesforce fácilmente. Se basan en el framework gráfico Flash Charting (aunque es limitado y antiguo), pero funcionan para necesidades básicas.
</apex:lineSeries></apex:barSeries></apex:pieSeries></apex:chart>
Which of the following methods can be annotated with @future in custom controllers?
A. Setter methods
B. Web service callouts
C. Constructor methods
D. Getter methods
B. Web service callouts
Methods that perform DML statements or web service callouts can use the @future annotation.
Getter, setter, and constructor methods in custom controllers can’t be annotated with @future since the processing of a page depends on these methods immediately returning or processing data.
When initializing a StandardSetController, which of the following data types is a valid argument that can be passed to its constructor?
A. List<sObject>
or Database.QueryLocator
B. Database.QueryLocator or Set<sObject>
C. Map<Id, sObject>
or List<sObject>
D. Set<sObject>
or Map<Id, sObject>
A. List<sObject>
or Database.QueryLocator
A StandardSetController can be instantiated using either a list (List<sObject>) or a query locator (Database.QueryLocator). Using other data types will throw an error during compile time.</sObject>
Note that if a query locator that returns more than 10,000 records is used to initialize a StandardSetController, a LimitException will be thrown. On the other hand, if a list with more than 10,000 records is used, the list will be automatically truncated to the maximum allowed number of records (10,000), and no exception will be thrown.
A developer needs to display a map that shows locations of properties sold by a real estate agent. How can this requirement be achieved using Visualforce?
A. Generate the map using the <apex:map>
component
B. Use the Salesforce JavaScript library for creating maps
C. Activate the map mode in Visualforce charts
D. Add the <apex:google>
component to generate the map
A. Generate the map using the <apex:map>
component
Salesforce provides the <apex:map>
component to support and display interactive maps on Visualforce pages. The map is capable of displaying multiple markers and comes with viewing controls for zooming and panning. Please note, however, that Visualforce mapping components are not available in Developer Edition orgs.
Salesforce does not provide a JavaScript library to its users for creating maps. There is no <apex:google>
component, and Visualforce charts do not have a map mode.
A developer is building a calculator application using a Visualforce page that will have two numerical input fields and perform an arithmetic operation based on the user input. What method should the developer use in order to accept and pass the input of the user to the controller?
A. Setter Method
B. Pass Method
C. Input Method
D. Accept Method
A. Setter Method
Setter Method – The [set] method is used to pass values from the Visualforce page to the controller. Setter methods pass user-specified values from page markup to a controller. Any setter methods in a controller are automatically executed before any action methods.
A developer has created a list of 11,000 records. What will happen if the developer instantiates a standard set controller using this list?
Choose 1 answer.
A. An exception will be thrown
B. The set will be instantiated without any issues
C. The set will be instantiated but the record list will be truncated
D. The set will be instantiated but paging functionality will be unstable
C. The set will be instantiated but the record list will be truncated
Instantiating a StandardSetController with a list of more than 10,000 records doesn’t throw an exception. Instead, the record list is truncated to the allowable limit. On the other hand, instantiating StandardSetController using a query locator returning more than 10,000 records causes a LimitException to be thrown.
🧠 Explanation:
When you use a StandardSetController in Apex, it supports up to 10,000 records.
If you instantiate it using a Database.QueryLocator and the query returns more than 10,000 records, an exception will be thrown.
BUT if you instantiate it using a List<sObject> (like in this case), no exception is thrown, but the list is truncated to the first 10,000 records.</sObject>
In this scenario, the developer is instantiating the controller using a list with 11,000 records, so the system will simply cut off (truncate) the list to 10,000 records.
Which of the following statements is true about displaying data on a Visualforce page?
Choose 1 answer.
A. JavaScript is required in order to bind components to data available via the controller.
B. Object data, but not global data, can be displayed on a Visualforce page.
C. The record to load on a page is identified via an id parameter included in the page URL.
D. The <apex:fieldValue> component can be used to display individual fields from a record.</apex:fieldValue>
C. The record to load on a page is identified via an id parameter included in the page URL.
To bind components to data available in the controller of a Visualforce page, the expression syntax is used such as {! Record.Name }. Both object (sObjects) and global (profiles, users, company, locale, etc.) data can be displayed on a Visualforce page using the expression syntax. The <apex:outputField>
component can be used to display individual fields from a record. There is no component called <apex:fieldValue>
in Visualforce.
If LeadExtA, LeadExtB, and LeadExtC in the code snippet below represent the names of Visualforce controller extensions, which of the following statements is true?
<apex:page standardController="Lead" extensions="LeadExtA,LeadExtB,LeadExtC"> <apex:outputText value="{!display}" /> </apex:page>
A. The Visualforce page will only use LeadExtA as long as no errors are encountered when loading.
B. LeadExtA, LeadExtB, or LeadExtC can be used without specifying the Lead standard controller.
C. If the same method exists in all extensions, the LeadExtC method overrides all the other methods.
D. LeadExtA, LeadExtB, and LeadExtC are controller extensions used by the Visualforce page.
D. LeadExtA, LeadExtB, and LeadExtC are controller extensions used by the Visualforce page.
Multiple controller extensions can be defined for a single page through a comma-separated list. Overrides are defined by whichever methods are defined in the leftmost extension. Meaning, if the same method exists in all the controller extensions in this scenario, the method from LeadExtA will override the method that is defined in LeadExtB and LeadExtC.
Extensions are required to extend either a standard controller or a custom controller. In this scenario, the Lead standard controller would be required. Extensions can be reused on different Visualforce pages. Developers should plan ahead and use inheritance either from a superclass or an interface to avoid too many constructors.=
Which of the statements is true regarding a StandardSetController?
Choose 1 answer.
A. It can be used to generate custom reports in Report Builder.
B. It can be used to perform bulk updates without writing code.
C. It can be used to perform or extend list controller functionality.
D. It can be used to process more than 10,000 records at a time.
C. It can be used to perform or extend list controller functionality.
The StandardSetController is an Apex class that can be used to perform or extend the functionality available in standard Visualforce page list controllers. Using the StandardSetController requires writing Apex code and is typically used in Visualforce pages that perform, for example, mass updates on records.
The maximum record limit for StandardSetController is 10,000 records. If a query locator is used for instantiating the StandardSetController to return more than 10,000 records, then a LimitException will be thrown. However, instantiating StandardSetController with a list of more than 10,000 records will not throw an exception, and instead trims the records down to the limit. Apex cannot be used to create reports in Report Builder.
A developer at Cosmic Solutions has uploaded a zip file called ‘StyleResource’ to a Salesforce org. The static resource contains a CSS file named ‘cosmic.css’. How can this CSS file be referenced in a Visualforce page that the developer is working on?
👇 Choose 1 answer:
A. <apex:include value="{!URLFOR($Resource.StyleResource, 'cosmic.css')}"/>
B. <apex:style value="{!URLFOR($Resource.StyleResource, 'cosmic.css')}"/>
C. <apex:stylesheet value="{!URLFOR($Resource.StyleResource, 'cosmic.css')}"/>
D. <apex:includeScript value="{!URLFOR($Resource.StyleResource, 'cosmic.css')}"/>
C. <apex:stylesheet value="{!URLFOR($Resource.StyleResource, 'cosmic.css')}"/>
A CSS stylesheet can be referenced in Visualforce pages by using the component <apex:stylesheet/>
. The attribute ‘value’ of this component uses the URL to the CSS file or a reference to a static resource via the function URLFOR.
<apex:style/>
is not a valid component in Visualforce. <apex:includeScript/>
is used in referencing JavaScript files, and <apex:include/>
allows another Visualforce page to be referenced in the current one.
Which step is valid for retrieving ‘First Priority’ case records in a custom Visualforce controller using a StandardSetController?
A. Accept StandardSetController in the controller constructor
B. Instantiate StandardSetController with a list or query locator
C. Use <apex:pageBlockTable>
with value set to {!getPriorityCases}
D. Set standardSetController=”FirstPriorityCaseController” on <apex:page>
✅ B. Instantiate StandardSetController with a list or query locator
This is the correct way to use StandardSetController inside a custom controller. It enables pagination and efficient handling of filtered records like ‘First Priority’ cases.