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

apex:variable

コンポーネントの本文内の指定された式の代わりに使用できるローカル変数です。<apex:variable> を使用して、ページ内で繰り返される冗長な式の数を減らします。

このコンポーネントを使用して、sObject の項目に対応しないコントローラメソッドのユーザ入力を取得します。sObject 項目で使用できるのは、<apex:inputfield>apex:outfield のみです。

注意: <apex:variable> は、<apex:dataTable> または <apex:repeat> などの反復コンポーネント内の再割り当てをサポートしていません。カウンタとして <apex:variable> の増分などを行った結果については、サポートまたは定義されていません。

1<!-- For this example to render properly, you must associate the Visualforce page 
2with a valid contact record in the URL. 
3For example, if 001D000000IRt53 is the contact ID, the resulting URL should be: 
4https://Salesforce_instance/apex/myPage?id=001D000000IRt53
5See the Visualforce Developer's Guide Quick Start Tutorial for more information. -->
6         
7<!-- Page: -->
8<apex:page controller="variableCon">
9    <apex:variable var="c" value="{!contact}" />
10        
11    <p>Greetings, {!c.LastName}.</p>
12</apex:page>
13
14/*** Controller ***/
15public class variableCon {
16    Contact contact;
17
18    public Contact getContact() {
19        if (contact == null){                      
20        contact = [select LastName from Contact where 
21            id = :ApexPages.currentPage().getParameters().get('id')];
22        }
23        return contact;
24    }
25}

属性

属性名 属性型 説明 必須かどうか API バージョン 通用範囲
id String ページの他のコンポーネントがコンポーネントを参照できるようにする識別子。 10.0 グローバル
rendered Boolean コンポーネントをページに表示するかどうかを指定する boolean 値。指定されていない場合、この値はデフォルトの true に設定されます。 10.0 グローバル
value Object 変数コンポーネントの本文内で変数によって表現できる式。 はい 10.0 グローバル
var String 変数コンポーネントの本文内で値の式を表現するために使用できる変数の名前。 はい 10.0 グローバル