Friday, 7 September 2012

Include One Visualforce Page within Another - Visualforce

Another way to include content from one page into another is to use the <apex:include> component. This lets you duplicate the entire contents of another page, without providing any opportunity to make any changes as you did with the templates.
  1. Create a new Visualforce page called EmbedsAnother.
  2. Use the following markup in the page:
    <apex:page sidebar="false" showHeader="false">
        <p>Test Before</p>
        <apex:include pageName="MainPage"/> <p>Test After</p>
    </apex:page>
Your original MainPage will be inserted verbatim.

Templates are a nice way to encapsulate page elements that need to be reused across several Visualforce pages. Visualforce pages just need to embed the template and define the content for the placeholders within the template. The <apex:include> component provides a simpler way of embedding one page within another.

2 comments:

  1. Small nitpick - the included page is going to be surround with a pair of "span" tags. This is a bummer as there's no way to remove these surrounding tags.

    - Sandeep

    ReplyDelete
  2. In addition to learning playing with tecninques, configuring networks and installations, I learned many other tech-tips on this website with in depth analysis. In addition to learning at salesforce online training was a completely different experience with exposures to various examples, presentations and videos which added to my knowledge greatly.

    ReplyDelete