No Results
Search Tips:
- Please consider misspellings
- Try different search keywords
Newer Version Available
StandardController Class
Use a StandardController when defining an extension for
a standard controller.
Namespace
ApexPages
Usage
StandardController objects reference the pre-built Visualforce controllers provided by Salesforce. The only time it is necessary to refer to a StandardController object is when defining an extension for a standard controller. StandardController is the data type of the single argument in the extension class constructor.
Instantiation
You can instantiate
a StandardController in the following way:
1swfobject.registerObject("clippy.codeblock-0", "9");ApexPages.StandardController sc = new ApexPages.StandardController(sObject);Example
The following example shows how a StandardController object can be used in the constructor for a standard controller extension:
1swfobject.registerObject("clippy.codeblock-1", "9");public class myControllerExtension {
2
3 private final Account acct;
4
5 // The extension constructor initializes the private member
6 // variable acct by using the getRecord method from the standard
7 // controller.
8 public myControllerExtension(ApexPages.StandardController stdController) {
9 this.acct = (Account)stdController.getRecord();
10 }
11
12 public String getGreeting() {
13 return 'Hello ' + acct.name + ' (' + acct.id + ')';
14 }
15}The following Visualforce markup shows how the controller extension from above can be used in a page:
1swfobject.registerObject("clippy.codeblock-2", "9");<apex:page standardController="Account" extensions="myControllerExtension">
2 {!greeting} <p/>
3 <apex:form>
4 <apex:inputField value="{!account.name}"/> <p/>
5 <apex:commandButton value="Save" action="{!save}"/>
6 </apex:form>
7</apex:page>