Visualforce Flashcards
After a Visualforce page redirect, the next page doesn’t show expected object information. What is the reason?
After a redirect, the controller clears the context state.
What is the limit on how many records a Visualforce iteration component can iterate over?
1,000 records. This is increased to 10,000 records in read only mode.
Which Visualforce component renders a ul or ol element with li items comprising the rows?
<apex:dataList>
</apex:dataList>
When is a view state deleted? When is it maintained?
It is deleted if a new get request is made by the user. If the user is redirected to a page that uses the same controller and the same or a proper subset of controller extensions, a postback request is made. When a postback request is made, the viewstate is maintained.
When returning a PageReference, named myPage, what must you first do to redirect to the new page?
Set the redirect attribute to true using myPage.setRedirect(true).
True or false: A Visualforce page can be launched as a quick action.
True.
Which Visualforce components are required for you to send actions through forms?
<apex:commandButton />
or <apex:commandLink/>
True or false: if you provide a constructor, you can still access the default, no-argument constructor.
False.
What is the standard signature for for an action method?
Is public, returns a PageReference, and contains no arguments.
What is the syntax to return a reference to the current page?
ApexPages.currentPage();
True or false: if you don’t provide a constructor, Apex provides a default, no-argument constructor.
True.
A Visualforce page uses the standard list controller with recordSetVar=”{!contacts}”. What is the syntax to create an <apex:pageBlockTable> to loop through the records?</apex:pageBlockTable>
<apex:pageBlockTable> value="{!contacts}" var="ct"></apex:pageBlockTable>
Which component adds the complete record details to a Visualforce page?
<apex:detail></apex:detail>
What is the syntax to include a Javascript file saved as a static resource named “jQuery”?
<apex:includescript value="{! $Resource.jQuery }"/>
How do you set a Visualforce page to read only mode?
Set the readOnly attribute of the <apex:page>
tag to true.
What is the syntax to output a formatted version of a field named myField from an object named myObject?
<apex:outputField value="{! myObject.myField}" />
What happens if any fields or objects referenced in a SOQL SELECT query using WITH SECURITY_ENFORCED are inaccessible to the running user?
A System.QueryException is thrown.
Which Visualforce tag adds AJAX support to another component?
<apex:actionSupport>
True or false: DML methods can be used in getter methods.
False.
Which character is the formula language operator that concatenates strings?
The & character.
Which property sets the action on an <apex:commandButton></apex:commandButton> component?
action
Which three components are used to include static resources?
<apex:includeScript>
, <apex:stylesheet>
, and <apex:image>
.
True or false: a controller extension uses the extends keyword in its class definition.
False.
Which method adds a message (usually an error message) to a page?
ApexPages.addMessages(message);
True or false: Visualforce expressions are case sensitive.
False. Visualforce expressions are case-insensitive.
Which formula returns a relative URL for an action, s-control, Visualforce page, or a file in a static resource archive in a Visualforce page?
URLFOR()
Which property provided by the standard list controller provides a menu of available filters for the object?
listViewOptions
What is a PageReference?
A reference to an instantiation of a page. Among other attributes, it consists of a URL and a set of query parameter names and values.
Which global variable is used for referencing static resources?
$Resource
What is the global merge field for referencing a standard Salesforce actions, such as editing/creating/deleting objects?
$Action
True or false: you cannot create a custom controller constructor that includes parameters.
True.
How do you add a standard controller to an Apex page?
standardController=”Account”
What is the order of method overrides in controller extensions?
Methods from whichever extension class is defined in the leftmost position of the “extensions” property will take precedence.
How do you add a custom controller to a page?
By referencing the name of the controller in the <apex:page>
component’s controller attribute.
Where are permissions for an Apex class checked?
Only at the top level.
True or false: custom controllers run in user mode.
False. Custom controllers run in system mode.
If a class is used as the entry point to an Apex transaction and with sharing/without sharing or not specified, what is the default?
without sharing
What is the syntax to display the first name of the logged in user in Visualforce?
{! $User.FirstName}
What is the only requirement to use a class as a custom controller?
That it exist.
What would be the syntax to create the URL for a new Account link?
{!URLFOR($Action.Account.New)}
How do you allow a Lightning web component to be used as an object-specific action?
Add the <target>lightning\_\_RecordAction</target>
to its configuration file.
Which Visualforce method returns the total number of records in the set?
resultSize
In an aura application, which init() event fires first?
The init() event of the innermost component fires first and then traverses outwards to the components higher in the hierarchy.
What is the syntax to retrieve the parameter ‘id’ from the current page?
ApexPages.currentPage().getParameters().get(‘id’);
Which actions do not supported Visualforce overrides?
Delete and custom actions.
What is a custom controller?
An Apex class that uses the default, no-argument constructor for the outer class.
Where does the WITH SECURITY_ENFORCED statement appear in a SOQL query?
Before ORDER BY, LIMIT, OFFSET, or any aggregate function clauses.
True or false: any setter methods in a controller are automatically executed before any action methods.
True.
Which exception is thrown when a validation error occurs?
DMLException.
How do you add styling to the <apex:outputField></apex:outputField> component?
Wrap it in <apex:pageBlock>
and <apex:pageBlockSection>
components.
A zipped folder has been uploaded as a static resource named jQueryMobile. It contains a PNG file located at images/icons-png/cloud-black.png. What is the proper syntax for including this in a Visualforce page?
<apex:image value=”{! URLFOR($Resource.jQueryMobile, ‘images/icons-png-cloud-black.png)}”
You are redirecting to a page called nextPage which will use the Contact controller. How do you pass along information about the current object to avoid the context state being lost?
Call nextPage.getParameters.put(‘id’, contact.id);
Which functions can be used to neutralize potential XSS threats?
HTMLENCODE(), JSENCODE(), JSINHTMLENCODE(), and JSENCODE(HTMLENCODE()).
Which Visualforce component creates a link to a URL (such as a View or Edit link)?
<apex:outputLink>
</apex:outputLink>
Which property sets the URL for the <apex:outputLink> component?</apex:outputLink>
value
What happens when you create a VF form without a record ID?
The page displays a blank data entry form that creates a new record when you click Save.
What is the view state?
It maintains the necessary information to maintain the state of the database between page requests. It is created if a page has an <apex:form>
component.
True or false: standard controllers run in user mode.
True.
Which component allows you to add a custom table of data to a page with Salesforce Classic styling?
<apex:pageBlockTable>
What is the syntax to retrieve the day value for today?
DAY(TODAY())
How do you make a Visualforce page available as a component in the Lightning App Builder?
Enable “Available for Lightning Experience, Lightning Communities, and the mobile app” through Setup.
What does the <apex:commandLink>
component do?
Creates a link that calls an action.
True or false: <apex:inputField>
respects user view/edit permissions.
True.
Which property of <apex:inputField></apex:inputField> references the associated field?
value
If a class is used as the entry point to an Apex transaction and inherited sharing is specified, what is the sharing setting?
with sharing
True or false: a Lightning web component must have an HTML file.
False. If it is a Service Component, such as a library, then it doesn’t require an HTML file.
Which two functions are used with pagination to check if you’ve reached the boundaries of the results?
hasNext and hasPrevious
True or false: <apex:inputField> respects metadata set on the field definition, such as whether the field is required or unique?</apex:inputField>
True.
How do you launch a Lightning web component in a window or modal?
Add <actionType>ScreenAction</actionType> to its configuration file.
What does declaring with sharing on an Apex class accomplish?
It enforces record permissions. It does not enforce object or field-level security permissions.
What is the preferred way to use the PageReference class to refer to an existing Visualforce page named “MyVisualforcePage”?
Page.MyVisualforcePage.
What is the formula syntax to add 7 days to today’s date?
TODAY() + 7
What is the expression syntax in Visualforce?
{! expression}
How do you add a controller extension to a Visualforce page?
By setting the “extensions” property on the <apex:page> component. Multiple extensions can be set by using a comma-separated list.</apex:page>
What is a controller extension?
Any Apex class containing a constructor that takes a single argument of type ApexPages.StandardController OR CustomControllerName, where CustomControllerName is the name of a custom controller you want to extend.
What are valid methods of preventing SOQL injection attacks?
Static queries with bind variables, String.escapeSingleQuotes(), Typecasting, replacing characters, and allowlisting.
What types of methods can Visualforce use?
Action, getter, and setter.
True or false: object-specific quick actions support Lightning web components.
True.
How would you upsert a variable called myList in user mode?
upsert as user myList;
What is the Visualforce global variable for getting details about the organization?
$Organization
How many records does the standard list controller display by default?
20.
What does the <apex:actionSupport> component do?</apex:actionSupport>
Makes an event (such as “onclick”, “onmouseover”, etc.) on another, named component, call an action.
Which Visualforce component displays form handling errors or messages?
<apex:pageMessages/ >
What is true about displaying a validation rule error on a Visualforce page when using a custom controller?
The error must be caught.
How do you turn off the related lists in the <apex:detail> component?</apex:detail>
<apex:detail></apex:detail>
True or false: an <apex:pageBlockTable> component must be contained in an <apex:pageBlock> component.</apex:pageBlock></apex:pageBlockTable>
True.
Which mode do Apex classes/triggers run in by default?
System mode.
Which Visualforce component embeds a related list?
<apex:relatedList></apex:relatedList>
What clause in SOQL statements enforced field and object-level security?
WITH SECURITY_ENFORCED
How are sObject fields updated by a controller if there are no setter methods defined?
If a Visualforce component is bound to an sObject stored in a controller, the sObject’s field are automatically set if changed by the user, as long as the sObject is saved or updated by a corresponding action method.
What is the difference between setting a standard controller and standard list controller in Visualforce?
Setting the recordSetVar property of the <apex:page> component.</apex:page>
Which formula do you use to find the square root of a number?
SQRT()
What is the syntax to add a column to an <apex:pageBlockTable> component?</apex:pageBlockTable>
<apex:column value={!myVar.myField} />