Apex and Visualforce Controllers: Linking to URLs

Anchor Tag with Href Attribute | apex:outputLink Component

Question

A link to a URL.

This component is rendered in HTML as an anchor tag with an href attribute.

Like its HTML equivalent, the body of an <apex:outputLink> is the text or image that displays as the link.

To add query string parameters to a link, use nested <apex:param> components.

Answers

Explanations

Click on the arrows to vote for the correct answer

A. B. C. D.

B.

The correct answer is B. apex:outputLink.

The apex:outputLink component is used to render a link to an external URL or an internal page. It is similar to an HTML anchor tag with an href attribute. The body of the apex:outputLink tag is the text or image that displays as the link.

Here's an example of how to use apex:outputLink:

html
<apex:outputLink value="https://www.example.com">Click here</apex:outputLink>

In this example, the value attribute is set to the URL that the link should point to, and the text "Click here" is used as the link text.

To add query string parameters to a link, you can use nested apex:param components. For example:

html
<apex:outputLink value="https://www.example.com"> Click here <apex:param name="param1" value="value1"/> <apex:param name="param2" value="value2"/> </apex:outputLink>

In this example, two apex:param components are nested within the apex:outputLink tag. The name attribute specifies the name of the query string parameter, and the value attribute specifies the value of the parameter.

The other options listed in the question are not correct:

A. apex:inputField is used to render a form input field for a specified field on a Salesforce object. C. apex:lineSeries is used to create a line chart in a Visualforce page. D. apex:emailPublisher is used to create a form for composing and sending emails in a Visualforce page.