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

apex:componentBody

このタグを使用して、カスタムコンポーネントの作成者は、ユーザがカスタムコンポーネントにコンテンツを挿入できる場所を定義できます。これは、特にカスタム反復コンポーネントを生成する場合に役立ちます。このコンポーネントは <apex:component> タグ内でのみ有効であり、カスタムコンポーネントあたり 1 つの定義のみを使用できます。

単純な例

1<!-- Page: --> 
2<apex:page>
3    <apex:outputText value="(page) This is before the custom component"/><br/>
4    <c:bodyExample>
5        <apex:outputText value="(page) This is between the custom component" /> <br/>
6    </c:bodyExample>
7    <apex:outputText value="(page) This is after the custom component"/><br/>
8</apex:page>
9
10<!-- Component: bodyExample -->
11<apex:component>
12    <apex:outputText value="First custom component output" /> <br/>
13    <apex:componentBody />
14    <apex:outputText value="Second custom component output" /><br/>
15</apex:component>

高度な例

1<!-- Page: --> 
2<apex:page >
3    <c:myaccounts var="a">
4        <apex:panelGrid columns="2" border="1">
5            <apex:outputText value="{!a.name}"/>
6            <apex:panelGroup >
7                <apex:panelGrid columns="1">
8                    <apex:outputText value="{!a.billingstreet}"/>
9                    <apex:panelGroup >
10                        <apex:outputText value="{!a.billingCity}, 
11                            {!a.billingState} {!a.billingpostalcode}"/>
12                    </apex:panelGroup>
13                </apex:panelGrid>
14            </apex:panelGroup>
15        </apex:panelGrid>
16    </c:myaccounts>
17</apex:page>
18
19<!-- Component: myaccounts-->
20<apex:component controller="myAccountsCon">
21    <apex:attribute name="var" type="String" description="The variable to represent
22                        a single account in the iteration."/>
23    <apex:repeat var="componentAccount" value="{!accounts}">
24        <apex:componentBody >
25            <apex:variable var="{!var}" value="{!componentAccount}"/>     
26        </apex:componentBody>
27    </apex:repeat>
28</apex:component>
29            
30/*** Controller ***/
31public class myAccountsCon {
32
33public List<Account> accounts {
34    get {
35    accounts = [select name, billingcity, billingstate, billingstreet, billingpostalcode 
36    from account where ownerid = :userinfo.getuserid()];
37
38    return accounts;
39    }
40    set;
41    }
42}

上述の例では次の HTML を表示します。

1<table width="100%" cellspacing="0" cellpadding="0" border="0" id="bodyTable" class="outer">
2    <!-- Start page content table -->
3    <tbody><tr><td id="bodyCell" class="oRight">
4        <!-- Start page content -->
5        <a name="skiplink"><img width="1" height="1"
6                        title="Content Starts Here" class="skiplink" 
7                        alt="Content Starts Here" src="/s.gif"/></a><span id="j_id0:j_id1">
8        <table border="1">
9            <tbody>
10                <tr>
11                    <td>sForce</td>
12                    <td><table>
13                        <tbody>
14                            <tr>
15                                <td>The Land's Mark @ One Market</td>
16                            </tr>
17                            <tr>
18                                <td>San Francisco, CA 94087</td>
19                            </tr>
20                        </tbody>
21                    </table>
22                    </td>
23                </tr>
24            </tbody>
25        </table>
26            <table border="1">
27                <tbody>
28                    <tr>
29                        <td>University U</td>
30                        <td>
31            <table>
32                <tbody>
33                    <tr>
34                        <td>888 N Euclid 
35                            Hallis Center, Room 501
36                            Tucson, AZ 85721
37                            United States</td>
38                   </tr>
39                    <tr>
40                        <td>Tucson, AZ </td>
41                    </tr>
42                </tbody>
43            </table>
44            </td>
45            </tr>
46        </tbody>
47            </table>
48            </span>
49    </td>
50    </tr>
51    </tbody>
52</table>

属性

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