Custom Component

Custom Component
A reusable piece of Visualforce page code that can be used in multiple different pages.

Setup >> Develop >> Components

Give component name as recordDisplay 
<apex:component>
    <apex:attribute name="record" description="The type of record we are viewing." type="Object" required="true"/>
                    
    <apex:pageBlock title="Viewing {!record}">  
        <apex:detail />
    </apex:pageBlock>
</apex:component>

It can be used in any page like following

<apex:page >
  <c:recordDisplay record="Account" />
</apex:page>
 Note: use record id in URL
Or in another page like
<apex:page>
  <c:recordDisplay record="Contact" />
</apex:page>
  Note: use record id in URL

Comments