Visualforce Flashcards

1
Q

After a Visualforce page redirect, the next page doesn’t show expected object information. What is the reason?

A

After a redirect, the controller clears the context state.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is the limit on how many records a Visualforce iteration component can iterate over?

A

1,000 records. This is increased to 10,000 records in read only mode.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Which Visualforce component renders a ul or ol element with li items comprising the rows?

A

<apex:dataList>
</apex:dataList>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

When is a view state deleted? When is it maintained?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

When returning a PageReference, named myPage, what must you first do to redirect to the new page?

A

Set the redirect attribute to true using myPage.setRedirect(true).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

True or false: A Visualforce page can be launched as a quick action.

A

True.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Which Visualforce components are required for you to send actions through forms?

A

<apex:commandButton /> or <apex:commandLink/>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

True or false: if you provide a constructor, you can still access the default, no-argument constructor.

A

False.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is the standard signature for for an action method?

A

Is public, returns a PageReference, and contains no arguments.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is the syntax to return a reference to the current page?

A

ApexPages.currentPage();

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

True or false: if you don’t provide a constructor, Apex provides a default, no-argument constructor.

A

True.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

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>

A

<apex:pageBlockTable> value="{!contacts}" var="ct"></apex:pageBlockTable>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Which component adds the complete record details to a Visualforce page?

A

<apex:detail></apex:detail>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is the syntax to include a Javascript file saved as a static resource named “jQuery”?

A

<apex:includescript value="{! $Resource.jQuery }"/>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

How do you set a Visualforce page to read only mode?

A

Set the readOnly attribute of the <apex:page> tag to true.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is the syntax to output a formatted version of a field named myField from an object named myObject?

A

<apex:outputField value="{! myObject.myField}" />

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

What happens if any fields or objects referenced in a SOQL SELECT query using WITH SECURITY_ENFORCED are inaccessible to the running user?

A

A System.QueryException is thrown.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

Which Visualforce tag adds AJAX support to another component?

A

<apex:actionSupport>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

True or false: DML methods can be used in getter methods.

A

False.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

Which character is the formula language operator that concatenates strings?

A

The & character.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

Which property sets the action on an <apex:commandButton></apex:commandButton> component?

A

action

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

Which three components are used to include static resources?

A

<apex:includeScript>, <apex:stylesheet>, and <apex:image>.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

True or false: a controller extension uses the extends keyword in its class definition.

A

False.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

Which method adds a message (usually an error message) to a page?

A

ApexPages.addMessages(message);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
Q

True or false: Visualforce expressions are case sensitive.

A

False. Visualforce expressions are case-insensitive.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
26
Q

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?

A

URLFOR()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
27
Q

Which property provided by the standard list controller provides a menu of available filters for the object?

A

listViewOptions

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
28
Q

What is a PageReference?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
29
Q

Which global variable is used for referencing static resources?

A

$Resource

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
30
Q

What is the global merge field for referencing a standard Salesforce actions, such as editing/creating/deleting objects?

A

$Action

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
31
Q

True or false: you cannot create a custom controller constructor that includes parameters.

A

True.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
32
Q

How do you add a standard controller to an Apex page?

A

standardController=”Account”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
33
Q

What is the order of method overrides in controller extensions?

A

Methods from whichever extension class is defined in the leftmost position of the “extensions” property will take precedence.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
34
Q

How do you add a custom controller to a page?

A

By referencing the name of the controller in the <apex:page> component’s controller attribute.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
35
Q

Where are permissions for an Apex class checked?

A

Only at the top level.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
36
Q

True or false: custom controllers run in user mode.

A

False. Custom controllers run in system mode.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
37
Q

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?

A

without sharing

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
38
Q

What is the syntax to display the first name of the logged in user in Visualforce?

A

{! $User.FirstName}

39
Q

What is the only requirement to use a class as a custom controller?

A

That it exist.

40
Q

What would be the syntax to create the URL for a new Account link?

A

{!URLFOR($Action.Account.New)}

41
Q

How do you allow a Lightning web component to be used as an object-specific action?

A

Add the <target>lightning\_\_RecordAction</target> to its configuration file.

42
Q

Which Visualforce method returns the total number of records in the set?

A

resultSize

43
Q

In an aura application, which init() event fires first?

A

The init() event of the innermost component fires first and then traverses outwards to the components higher in the hierarchy.

44
Q

What is the syntax to retrieve the parameter ‘id’ from the current page?

A

ApexPages.currentPage().getParameters().get(‘id’);

45
Q

Which actions do not supported Visualforce overrides?

A

Delete and custom actions.

46
Q

What is a custom controller?

A

An Apex class that uses the default, no-argument constructor for the outer class.

47
Q

Where does the WITH SECURITY_ENFORCED statement appear in a SOQL query?

A

Before ORDER BY, LIMIT, OFFSET, or any aggregate function clauses.

48
Q

True or false: any setter methods in a controller are automatically executed before any action methods.

A

True.

49
Q

Which exception is thrown when a validation error occurs?

A

DMLException.

50
Q

How do you add styling to the <apex:outputField></apex:outputField> component?

A

Wrap it in <apex:pageBlock> and <apex:pageBlockSection> components.

51
Q

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?

A

<apex:image value=”{! URLFOR($Resource.jQueryMobile, ‘images/icons-png-cloud-black.png)}”

52
Q

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?

A

Call nextPage.getParameters.put(‘id’, contact.id);

53
Q

Which functions can be used to neutralize potential XSS threats?

A

HTMLENCODE(), JSENCODE(), JSINHTMLENCODE(), and JSENCODE(HTMLENCODE()).

54
Q

Which Visualforce component creates a link to a URL (such as a View or Edit link)?

A

<apex:outputLink>
</apex:outputLink>

55
Q

Which property sets the URL for the <apex:outputLink> component?</apex:outputLink>

A

value

56
Q

What happens when you create a VF form without a record ID?

A

The page displays a blank data entry form that creates a new record when you click Save.

57
Q

What is the view state?

A

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.

58
Q

True or false: standard controllers run in user mode.

A

True.

59
Q

Which component allows you to add a custom table of data to a page with Salesforce Classic styling?

A

<apex:pageBlockTable>

60
Q

What is the syntax to retrieve the day value for today?

A

DAY(TODAY())

61
Q

How do you make a Visualforce page available as a component in the Lightning App Builder?

A

Enable “Available for Lightning Experience, Lightning Communities, and the mobile app” through Setup.

62
Q

What does the <apex:commandLink> component do?

A

Creates a link that calls an action.

63
Q

True or false: <apex:inputField> respects user view/edit permissions.

A

True.

64
Q

Which property of <apex:inputField></apex:inputField> references the associated field?

A

value

65
Q

If a class is used as the entry point to an Apex transaction and inherited sharing is specified, what is the sharing setting?

A

with sharing

66
Q

True or false: a Lightning web component must have an HTML file.

A

False. If it is a Service Component, such as a library, then it doesn’t require an HTML file.

67
Q

Which two functions are used with pagination to check if you’ve reached the boundaries of the results?

A

hasNext and hasPrevious

68
Q

True or false: <apex:inputField> respects metadata set on the field definition, such as whether the field is required or unique?</apex:inputField>

A

True.

69
Q

How do you launch a Lightning web component in a window or modal?

A

Add <actionType>ScreenAction</actionType> to its configuration file.

70
Q

What does declaring with sharing on an Apex class accomplish?

A

It enforces record permissions. It does not enforce object or field-level security permissions.

71
Q
A
72
Q

What is the preferred way to use the PageReference class to refer to an existing Visualforce page named “MyVisualforcePage”?

A

Page.MyVisualforcePage.

73
Q

What is the formula syntax to add 7 days to today’s date?

A

TODAY() + 7

74
Q

What is the expression syntax in Visualforce?

A

{! expression}

75
Q

How do you add a controller extension to a Visualforce page?

A

By setting the “extensions” property on the <apex:page> component. Multiple extensions can be set by using a comma-separated list.</apex:page>

76
Q

What is a controller extension?

A

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.

77
Q

What are valid methods of preventing SOQL injection attacks?

A

Static queries with bind variables, String.escapeSingleQuotes(), Typecasting, replacing characters, and allowlisting.

78
Q

What types of methods can Visualforce use?

A

Action, getter, and setter.

79
Q

True or false: object-specific quick actions support Lightning web components.

A

True.

80
Q

How would you upsert a variable called myList in user mode?

A

upsert as user myList;

81
Q

What is the Visualforce global variable for getting details about the organization?

A

$Organization

82
Q

How many records does the standard list controller display by default?

A

20.

83
Q

What does the <apex:actionSupport> component do?</apex:actionSupport>

A

Makes an event (such as “onclick”, “onmouseover”, etc.) on another, named component, call an action.

84
Q

Which Visualforce component displays form handling errors or messages?

A

<apex:pageMessages/ >

85
Q

What is true about displaying a validation rule error on a Visualforce page when using a custom controller?

A

The error must be caught.

86
Q

How do you turn off the related lists in the <apex:detail> component?</apex:detail>

A

<apex:detail></apex:detail>

87
Q

True or false: an <apex:pageBlockTable> component must be contained in an <apex:pageBlock> component.</apex:pageBlock></apex:pageBlockTable>

A

True.

88
Q

Which mode do Apex classes/triggers run in by default?

A

System mode.

89
Q

Which Visualforce component embeds a related list?

A

<apex:relatedList></apex:relatedList>

90
Q

What clause in SOQL statements enforced field and object-level security?

A

WITH SECURITY_ENFORCED

91
Q

How are sObject fields updated by a controller if there are no setter methods defined?

A

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.

92
Q

What is the difference between setting a standard controller and standard list controller in Visualforce?

A

Setting the recordSetVar property of the <apex:page> component.</apex:page>

93
Q

Which formula do you use to find the square root of a number?

A

SQRT()

94
Q

What is the syntax to add a column to an <apex:pageBlockTable> component?</apex:pageBlockTable>

A

<apex:column value={!myVar.myField} />