3

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}" />
    </apex:repeat>
</apex: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?

4
  • Are you trying to show all pages or a single page ? I'm not entirely sure I understand what you're trying to do. Commented Oct 2, 2014 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
    Commented Oct 2, 2014 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
    Commented Oct 2, 2014 at 15:01
  • possible duplicate of this question: "apex:include resolves its reference before any other element on a page"
    – BarCotter
    Commented Oct 2, 2014 at 15:02

1 Answer 1

2

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

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

Then direct people to the URL:

/apex/DynamicInclude?include1=ThePage

Is this something you can build upon?

1
  • 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
    Commented Oct 3, 2014 at 10:15

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .