Author Archives: Biswajeet

About Biswajeet

Biswajeet is my Name, Success is my Aim and Challenge is my Game. Risk & Riding is my Passion and Hard Work is my Occupation. Love is my Friend, Perfection is my Habit and Smartness is my Style. Smiling is my Hobby, Politeness is my Policy and Confidence is my Power.

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:pageBlock mode="edit" title="Account">
            <apex:pageBlockButtons >
                <apex:commandButton action="{!save}" value="Save"/>
                <apex:pageBlockSection columns="2" title="Account Information">
                    <apex:inputField value="{!Account.Name}" required="true"/>
                    <apex:inputField value="{!Account.Phone}"/>

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;

Add Fields in ApexPages.StandardController

If you want any fields value then you need add the field API name in standard controller.

public with sharing class AccountControllerExt
	public Account acc {get;set;}
	public AccountControllerExt(ApexPages.StandardController stdController)
		stdController.addFields(new List<String>{'Name', 'Region__c', 'TAX_ID_Number__c'});
		this.acc = (Account)stdController.getRecord();