November 9, 2012

How to Include One Visualforce Page within Another

Sample Code:

    <p>Test Before</p>
    <apex:include pageName="MainPage"/>
    <p>Test After</p>

here MainPage is a another Visualforce page.

<apex:page >
Main Page : Welcome to Infallible Techie Site



  1. What happens if MainPage is attached to a specific controller e.g,
    <apex:page standardController="Account>.

    How do you pass the correct Account Id to the MainPage if the Primary Page is a stand alone page?

    1. Add extensions="Class_Name" for populating account id.


    2. Where would you add the extension?
      In the main page, or the primary page?

  2. If both the pages are of different standand controller objects and have different can we call one visual force page data into another visual force page.
    For Example : I have a managed package installed in sandbox.Which has Visual force page created on opportunity object.I have created a custom visual force page in a PDF format on Quote object .So can get data of visual force page displayed in a custom visual force page in a PDF format.

    If yes,can u help me out with an example.Any suggestion plz.