0

I want to show a simple vf page on detail page layout of 10 objects by dragging the vf on to the page layout. Right now, I am writing one vf page for each object as below:

AccountVf.page:

<apex:page StandardController="Account">
    We are on Account Page
</apex:page>

ContactVf.page:

<apex:page StandardController="Contact">
    We are on Contact Page
</apex:page>

Is there a easy way of doing this, instead of creating new visualforce page for each object?

2

No. If you want common markup to share across pages for multiple objects, you would move the common markup into a Visualforce Component instead of Visualforce Page.

<apex:component>
    <apex:attribute name="sObjectType" type="String" required="true"
        description="Type of SObject for which this component renders" />

    We are on {!sObjectType} Page
</apex:component>

Then you'd use this component in your pages.

<apex:page standardController="Account">
    <c:MyComponent sObjectType="Account" />
</apex:page>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.