I have VF Page which needs to be added to 2 different Object's Page Layout section. I am not able to refer the VF page unless VFP's StandardController attribute refers to the Object. Is there any way to refer my common VF Page into multiple object Page layouts? I dont want to create multiple VF Pages with Same code (Only diff would be the Standardcontroller).

One Design approach is have two VFP with different Standard contoller and include my page in both the VFP.

VF Page 1
<apex:page standardController="CustomObject1__c" extensions="Controller"> 
      <apex:include pageName="commonVFPage"/>

VF Page 2
<apex:page standardController="CustomObject2__c" extensions="Controller"> 
      <apex:include pageName="commonVFPage"/>

Is there any other good way to approach this problem?

  • AFAIK standardcontroller can support only one string at a time, so you cannot avoid 2 pages but as techbusinessman suggests component will be the way to go – Rao Dec 8 '15 at 17:41

You will want to move your VF code to a VF Component Creating and Using Custom Components.

You can then create two VF pages which each include the same component (the standard controller is then on the VF Page and you can use a custom controller for your component).

This architecture will allow you to keep your code in one place but use on two standard pages.

| improve this answer | |

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.