I have the following code, and I would like to render as PDF:

<apex:page controller="MyController">
    <apex:repeat value="{!pagesToShow}" var="page">     
            <apex:include pageName="{!page}" />

templatesToShow is a list in the controller that holds VF pages.

This doesn't works because apex:include is looking the page variable in the controller. But It's not here because it's within the repeat scope.

Any advice to get dynamic page showing?

  • Are you trying to show all pages or a single page ? I'm not entirely sure I understand what you're trying to do. – Samuel De Rycke Oct 2 '14 at 14:47
  • It would be worth updating your question to mention that you are getting a compilation error saying "Unknown property 'MyController.page" on the apex:include line – BarCotter Oct 2 '14 at 14:56
  • What I need is generate a PDF which have several sections. Each section can have different design and templating depending on settings. – junjs Oct 2 '14 at 15:01
  • possible duplicate of this question: "apex:include resolves its reference before any other element on a page" – BarCotter Oct 2 '14 at 15:02

You can (in a limited fashion) do dynamic includes. The trick is to use the $Page global like this:

    <apex:include pageName="{!$Page[$CurrentPage.parameters.include1]}" />

Then direct people to the URL:


Is this something you can build upon?

  • I can give it a shot, but a quick thought is that I still need iterate through a list because I can receive a different template (page) for each section, and I can have n sections. – junjs Oct 3 '14 at 10:15

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.