+ Start a Discussion
MVJMVJ 

Change the output label

I have the following visual force page:
 
Code:
    <apex:pageBlock title="Account">
    <apex:pageBlockSection title="Account Detail" columns="2" collapsible="true">
        <apex:outputField value="{!Account.Name}" id="AccountName"></apex:OutputField><apex:outputField value="{!Account.Owner.name}"></apex:OutputField>
        <apex:outputField value="{!Account.Site}"></apex:OutputField><apex:outputText></apex:outputText>
        <apex:outputField value="{!Account.BillingStreet}"></apex:OutputField><apex:outputText></apex:outputText>
        <apex:outputField value="{!Account.BillingCity}"></apex:OutputField><apex:outputText></apex:outputText>
        <apex:outputField value="{!Account.BillingState}"></apex:OutputField><apex:outputText></apex:outputText>
        <apex:outputField value="{!Account.BillingPostalCode}"></apex:OutputField><apex:outputText></apex:outputText>
    </apex:pageBlockSection>
    </apex:pageBlock>

 
It outputs the field label for the specific object.  When it outputs the Account Owner it displays the Label as "Name" when I want the label to read "Account Owner".  I have tried to use the Title option and can noit get that to work.  I also tried to use the outPutLabel and that does not seem to work either.
 
So how do I change the default label on this page.
 
Thanks
 
 
Best Answer chosen by Admin (Salesforce Developers) 
MVJMVJ

Thanks Sam That worked like a charm.

Here is the updated Code:

Code:
    <apex:pageBlock title="Account">
    <apex:pageBlockSection title="Account Detail" columns="2" collapsible="true">
        <apex:outputField value="{!Account.Name}" id="AccountName"></apex:OutputField>
        <apex:pageBlockSectionItem>
            <apex:outputLabel value="Account Owner" for="AccountOwner"></apex:outputLabel>
            <apex:outputField value="{!Account.Owner.name}" id="AccountOwner"></apex:OutputField>
        </apex:pageBlockSectionItem>
        <apex:outputField value="{!Account.Site}"></apex:OutputField><apex:outputText></apex:outputText>
        <apex:outputField value="{!Account.BillingStreet}"></apex:OutputField><apex:outputText></apex:outputText>
        <apex:outputField value="{!Account.BillingCity}"></apex:OutputField><apex:outputText></apex:outputText>
        <apex:outputField value="{!Account.BillingState}"></apex:OutputField><apex:outputText></apex:outputText>
        <apex:outputField value="{!Account.BillingPostalCode}"></apex:OutputField><apex:outputText></apex:outputText>
    </apex:pageBlockSection>
    </apex:pageBlock>


 

All Answers

Sam.arjSam.arj
I have had that problem too!
Use outputLabel instead of outputField and combine it with another outputLabel to show your text "Account Owner"

jwetzlerjwetzler
use pageBlockSectionItem with an outputLabel and an outputField to stop the auto generation of labels.
MVJMVJ

Thanks Sam That worked like a charm.

Here is the updated Code:

Code:
    <apex:pageBlock title="Account">
    <apex:pageBlockSection title="Account Detail" columns="2" collapsible="true">
        <apex:outputField value="{!Account.Name}" id="AccountName"></apex:OutputField>
        <apex:pageBlockSectionItem>
            <apex:outputLabel value="Account Owner" for="AccountOwner"></apex:outputLabel>
            <apex:outputField value="{!Account.Owner.name}" id="AccountOwner"></apex:OutputField>
        </apex:pageBlockSectionItem>
        <apex:outputField value="{!Account.Site}"></apex:OutputField><apex:outputText></apex:outputText>
        <apex:outputField value="{!Account.BillingStreet}"></apex:OutputField><apex:outputText></apex:outputText>
        <apex:outputField value="{!Account.BillingCity}"></apex:OutputField><apex:outputText></apex:outputText>
        <apex:outputField value="{!Account.BillingState}"></apex:OutputField><apex:outputText></apex:outputText>
        <apex:outputField value="{!Account.BillingPostalCode}"></apex:OutputField><apex:outputText></apex:outputText>
    </apex:pageBlockSection>
    </apex:pageBlock>


 

This was selected as the best answer
jwetzlerjwetzler
Just out of curiosity, what's up with all the empty outputText components?  You can specify columns="1" if what you want is one column.
MVJMVJ

Yes I know that I can define the columns as 1.  They are place holders.  I will be adding other data elements there as I continue to build this out further.  Just want to make sure that  adress lines all stayed in the left column for now.

Thanks