anusha(salesforce developer)

Friday 29 July 2016

How to use <apex:outputField>  in Visualforce Page?

<apex:outputField> :
A read-only display of a label and value for a field on a Salesforce object. An < apex:outputField > component respects the attributes of the associated field, including how it should be displayed to the user. For example, if the specified < apex:outputField > component is a currency field, the appropriate currency symbol is displayed. Likewise, if the < apex:outputField > component is a lookup field or URL, the value of the field is displayed as a link. 

This tag supports following attributes:
Attribute
Description
dir
The direction in which the generated HTML component should be read. Possible values include "RTL" (right to left) or "LTR" (left to right).
id
An identifier that allows the output field component to be referenced by other components in the page.
label
A string value to be used as component label.
lang
The base language for the generated HTML output, for example, "en" or "en-US".
rendered
A Boolean value that specifies whether the component is rendered on the page. If not specified, this value defaults to true.
style
The style used to display the output field component, used primarily for adding inline CSS styles. This attribute may not work for all values. If your text requires a class name, use a wrapping span tag.
styleClass
The style class used to display the output field component, used primarily to designate which CSS styles are applied when using an external CSS stylesheet. This attribute may not work for all values. If your text requires a class name, use a wrapping span tag.
title
The text to display as a tooltip when the user's mouse pointer hovers over this component.
value
A merge field that references the Salesforce field that is associated with this output field. For example, if you want to display an output field for an account's name field, use value="{!account.name}". You cannot associate this output field with a currency merge field if that field value is calculated using dated exchange rates.

Visualforce Example:

<apex:page standardController="Opportunity" tabStyle="Opportunity">
<apex:pageBlock > 
<apex:pageBlockSection title="Opportunity Information"> 
<apex:outputField value="{!opportunity.name}"/>
<apex:outputField value="{!opportunity.amount}"/> 
<apex:outputField value="{!opportunity.closeDate}"/>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:page>


save image


No comments:

Post a Comment