PD1 Visualforce Pages 3 — Questions and Answers
Question 1: Which Visualforce global variable provides access to custom labels?
- $Label (Correct answer)
- $CustomLabel
- $Labels
- $Setup
Correct answer: $Label
The $Label global variable allows you to reference custom labels in Visualforce expressions, e.g., {!$Label.My_Label}.
Question 2: How does <apex:actionPoller> work in a Visualforce page?
- It polls an external REST endpoint on a timer
- It periodically calls a controller action at a specified interval to refresh page data (Correct answer)
- It polls the database for record changes using streaming API
- It refreshes the entire page at a specified interval
Correct answer: It periodically calls a controller action at a specified interval to refresh page data
<apex:actionPoller> invokes a controller action repeatedly at a defined interval (minimum 5 seconds) to enable auto-refreshing data.
Question 3: Which attribute on <apex:outputField> ensures the field is rendered using its associated field metadata including label?
- showLabel='true'
- The label is always rendered automatically
- You must wrap it in <apex:pageBlockSectionItem> (Correct answer)
- Use the 'label' attribute explicitly
Correct answer: You must wrap it in <apex:pageBlockSectionItem>
Wrapping <apex:outputField> inside <apex:pageBlockSectionItem> renders the field with its metadata-driven label on the left side.
Question 4: What is the maximum number of SOQL queries allowed in a Visualforce page request (non-readOnly)?
- 50
- 100 (Correct answer)
- 150
- 200
Correct answer: 100
Standard Visualforce page requests follow the same governor limits as Apex: 100 SOQL queries per transaction.
Question 5: Which component should you use to render a Visualforce page inside another Visualforce page?
- <apex:insert>
- <apex:include> (Correct answer)
- <apex:component>
- <apex:iframe>
Correct answer: <apex:include>
<apex:include> embeds another Visualforce page's content inline within the current page, sharing the same view state.
Question 6: In Visualforce, which expression syntax is used to escape potentially unsafe user input for XSS prevention?
- {!HTMLENCODE(value)} (Correct answer)
- {!ENCODE(value)}
- {!JSENCODE(value)}
- {!URLENCODE(value)}
Correct answer: {!HTMLENCODE(value)}
HTMLENCODE() encodes special HTML characters to prevent cross-site scripting when outputting user data in HTML context.
Question 7: What does the 'escape' attribute on <apex:outputText> control?
- Whether special characters in the value are URL-encoded
- Whether HTML entities in the value are escaped before rendering (Correct answer)
- Whether the component hides sensitive data from logs
- Whether the output value is truncated at 255 characters
Correct answer: Whether HTML entities in the value are escaped before rendering
Setting escape='false' allows raw HTML to be rendered, while escape='true' (the default) converts HTML characters to entities to prevent XSS.
Which Visualforce global variable provides access to custom labels?