Why formatting output ?
Most of the time, you don't want to display the date, string, number in raw format to the User. It has be formatting to different standards & user conventions before displaying to user.How to Formatting Ouput ?
When you want to format a Date, String, Number, i have seen developers formatting them in Apex Class & showing them in Visualforce. That is not required, we can use OutputText with param tag to format the output.
What types of data can be formatted ?
you can format String, Date & Number types using OutputText tag
Where is the Code ?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<apex:page standardController="Opportunity"> | |
<!-- Format - String --> | |
<apex:sectionHeader title="Formatting - String"/> | |
<apex:outputText value="The Opportunity Name is {0}"> | |
<apex:param value="{!Opportunity.Name}"/> | |
</apex:outputText> | |
<!-- Format - Number --> | |
<apex:sectionHeader title="Formatting - Number"/> | |
<apex:outputText value="{0, number, 00,000.00}"> | |
<apex:param value="{!Opportunity.Amount}"/> | |
</apex:outputText> | |
<!-- Format - Date --> | |
<apex:sectionHeader title="Formatting - Date"/> | |
<apex:outputText value="{0, date, YYYY/MM/DD}"> | |
<apex:param value="{!Opportunity.CloseDate}"/> | |
</apex:outputText> | |
</apex:page> |
thanks
ReplyDelete