tyoshikawa1106のブログ

- Force.com Developer Blog -

SFDC:Componentとattribute

ページから Componentに値を渡す場合は、attributeタグを使用します。

 

ページからComponentを呼び出すときは下記のように記載します。

<apex:page>
    <c:myComponent myValue="My component's value" borderColor="red" />
</apex:page>

 

Component側では下記のように記載します。

<apex:component>
    <apex:attribute name="myValue" type="String" />
    <apex:attribute name="borderColor" type="String" />

    <h1 style="border:{!borderColor}">
        <apex:outputText value="{!myValue}"/>
    </h1>
</apex:component>

 

Component側でattibuteタグのname項目に値を指定する感じです。 
Component内ではattributeタグのnameを指定することで値を使用できます。