この文章は Salesforce 機械翻訳システムを使用して翻訳されました。詳細はこちらをご参照ください。
英語に切り替える

StandardController クラス

標準コントローラーの拡張を定義する場合は、StandardController を使用します。

名前空間

ApexPages

使用方法

StandardController オブジェクトは、Salesforce が提供する、開発済みの Visualforce コントローラーを参照します。StandardController オブジェクトを参照する必要があるのは、標準コントローラーの拡張を定義する場合のみです。StandardController は、拡張クラスコンストラクターの単一引数のデータ型です。

インスタンス化

次の方法で、StandardController をインスタンス化することができます。
1ApexPages.StandardController sc = new ApexPages.StandardController(sObject);

次の例では、StandardController オブジェクトの標準コントローラー拡張のコンストラクターでの使用方法を示します。

1public 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}

次の Visualforce マークアップは、上記のコントローラー拡張をページ内で使用する方法を示します。

1<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>