No Results
Search Tips:
- Please consider misspellings
- Try different search keywords
カスタムコンポーネントの属性
標準の Visualforce マークアップ以外に、<apex:component> タグの本文でも、Visualforce ページで使用するときにカスタムコンポーネントに渡すことができる属性を指定できます。このような属性の値は、その後、コンポーネントやコンポーネントのコントローラ内 (該当する場合) で直接使用できます。
属性は <apex:attribute> タグで定義されます。たとえば、次のカスタムコンポーネントの定義では、value および borderColor という名前の 2 つの必須属性を指定します。これらの属性の値は、次の標準の {! } という Visualforce の式言語構文を使用してカスタムコンポーネントの定義で参照されます。
1swfobject.registerObject("clippy.component_attributes3", "9");<apex:component>
2 <!-- Attribute Definitions -->
3 <apex:attribute name="myValue" description="This is the value for the component."
4 type="String" required="true"/>
5 <apex:attribute name="borderColor" description="This is color for the border."
6 type="String" required="true"/>
7
8 <!-- Component Definition -->
9 <h1 style="border:{!borderColor};"/>
10 <apex:outputText value="{!myValue}"/>
11 </h1>
12</apex:component> 次のマークアップで Visualforce ページにこのコンポーネントを使用します。
1swfobject.registerObject("clippy.component_attributes5", "9");<c:myComponent myValue="My value" borderColor="red"/><apex:attribute> タグには、name、description、および type 属性の値が必要です。
- name 属性は Visualforce ページでカスタム属性を参照できる方法を定義します。属性の name は、コンポーンネント内で一意にする必要があります。
- description 属性は、カスタムコンポーネントが保存されたらコンポーネントの参照ライブラリに表示される属性のヘルプテキストを定義します。このカスタムコンポーネントは、使用可能な標準コンポーネントも含む参照ライブラリにリストされます。
- type 属性は属性の Apex データ型を定義します。type 属性は次のデータ型のみを値として使用できます。
- string、integer、または boolean などのプリミティブデータ型
- Account などの sObject、My_Custom_Object__c、または汎用型の SObject
- String[]、Contact[] などの配列表記を使用して指定する一次元リスト
- type="map" を使用して指定する対応付け。対応付けの特定のデータ型を指定する必要はありません。
- カスタム Apex クラス
その他の <apex:attribute> 属性についての詳細は、「apex:attribute」を参照してください。