What is the difference between outputfield and outputtext?

apex:outputText: Displays text on a Visualforce page.

apex:outputField: A read-only display of a label and value for a field on a Salesforce object.

Sample Code:

Visualforce Page:

<apex:page controller="Sample" tabStyle="Account">
<apex:form >
<apex:pageMessages />
    <apex:pageBlock id="pg">
        <apex:pageBlockSection columns="1">
            <apex:outputText >Sample Output Text</apex:outputText>
            <apex:outputField value="{!acct.Name}"/>


Apex Class:

public class Sample {
    public Account acct {get;set;}
    public Sample() {
       acct = [SELECT Name, Industry FROM Account LIMIT 1];



1 comment:

Sharing is Caring!!! Share this with your friends!!!

submit to reddit