Tag Archives: Salesforce.com

Show =required information along with red bar on the Page Block section of VF Page

Set the apex:pageBlock mode="edit".

<apex:page standardController="Account">
	<apex:form>
        <apex:pageBlock mode="edit" title="Account">
            <apex:pageBlockButtons >
                <apex:commandButton action="{!save}" value="Save"/>
            </apex:pageBlockButtons>
            <apex:outputPanel>
                <apex:pageBlockSection columns="2" title="Account Information">
                    <apex:inputField value="{!Account.Name}" required="true"/>
                    <apex:inputField value="{!Account.Phone}"/>
                </apex:pageBlockSection>
            </apex:outputPanel>
        </apex:pageBlock>
    </apex:form>
</apex:page>

Redirecting Back to Previous Page Using Visualforce Page StandardController

Visualforce Page Button:

<apex:commandButton action="{!back}" value="Back"/>

Apex Controller:

public with sharing class ExampleController
{
    private ApexPages.StandardController sctrl;
    public SaveAndReturnController(ApexPages.StandardController stdController)
    {
        this.sctrl = stdController;
    }
 
    public PageReference back()
    {
        PageReference cancel = sctrl.cancel();
        return cancel;
    }
}