Displays text on a Visualforce page. You can customize the appearance of <apex:outputText> using CSS styles, in which case the generated text is wrapped in an HTML <span> tag. You can also escape the rendered text if it contains sensitive HTML and XML characters. This component does take localization into account.
Use with nested param tags to format the text values, where {n} corresponds to the n-th nested param tag. The value attribute supports the same syntax as the MessageFormat class in Java. See the MessageFormat class JavaDocs for more information.
Warning:Encrypted custom fields that are embedded in the <apex:outputText> component display in clear text. The <apex:outputText> component doesn't respect the View Encrypted Data permission for users. To prevent showing sensitive information to unauthorized users, use the <apex:outputField> tag instead.
This component supports HTML pass-through attributes using the "html-" prefix. Pass-through attributes are attached to the generated container <span> tag.
<apex:page> <apex:outputText style="font-style:italic" value="This is {0} text with {1}."> <apex:param value="my"/> <apex:param value="arguments"/> </apex:outputText> </apex:page>
The example above renders the following HTML:
<span id="theText" style="font-style:italic">This is my text with arguments.</span>
<apex:page> <apex:outputText value="The unformatted time right now is: {!NOW()}" /> <br/> <apex:outputText value="The formatted time right now is: {0,date,yyyy.MM.dd G 'at' HH:mm:ss z}"> <apex:param value="{!NOW()}" /> </apex:outputText> </apex:page>
The example above renders the following HTML:
The unformatted time right now is: 11/20/2004 3:49 PM <br /> The formatted time right now is: 2004.11.20 AD at 23:49:02 GMT
<!-- For this example to render properly, you must associate the Visualforce page with a valid account record in the URL. For example, if 001D000000IeChM is the account ID, the resulting URL should be: https://Salesforce_instance/apex/myPage?id=001D000000IeChM See the Visualforce Developer's Guide Quick Start Tutorial for more information. --> <apex:page standardController="Account"> It is worth: <apex:outputText value="{0, number, 000,000.00}"> <apex:param value="{!Account.AnnualRevenue}" /> </apex:outputText> </apex:page>
The example above renders the following HTML:
It is worth: 500,000,000.00
Attribute Name | Attribute Type | Description | Required? | API Version | Access |
---|---|---|---|---|---|
dir | String | The direction in which the generated HTML component is read. Possible values include "RTL" (right to left) or "LTR" (left to right). | 10.0 | global | |
escape | Boolean | A Boolean value that specifies whether sensitive HTML and XML characters should be escaped in the HTML output generated by this component. If you do not specify escape="false", the character escape sequence displays as written. Be aware that setting this value to "false" may be a security risk because it allows arbitrary content, including JavaScript, that could be used in a malicious manner. | 10.0 | global | |
id | String | An identifier that allows the outputText component to be referenced by other components in the page. | 10.0 | global | |
label | String | A text value that allows to display a label next to the output text | 23.0 | ||
lang | String | The base language for the generated HTML output, for example, "en" or "en-US". For more information on this attribute, see the W3C specifications. | 10.0 | global | |
rendered | Boolean | A Boolean value that specifies whether the component is rendered on the page. If not specified, this value defaults to true. | 10.0 | global | |
style | String | The style used to display the outputText component, used primarily for adding inline CSS styles. | 10.0 | global | |
styleClass | String | The style class used to display the outputText component, used primarily to designate which CSS styles are applied when using an external CSS stylesheet. | 10.0 | global | |
title | String | The text to display as a tooltip when the user's mouse pointer hovers over this component. | 10.0 | global | |
value | Object | The text displayed when this component is rendered. This value supports the same syntax as the MessageFormat class in Java. For more information on the MessageFormat class, see http://java.sun.com/j2se/1.4.2/docs/api/java/text/MessageFormat.html. | 10.0 | global |