0

I have a managed package with this issue:

I have a Visualforce PDF page that optionally includes another page at runtime. I use an apex:include which works fine in development unpackaged. Here is the beginning of the Visualforce page including the section where the second page is optionally included:

<apex:page controller="CustomerInvoiceBatchController" showHeader="false" sidebar="false" applyHtmlTag="false" applyBodyTag="false" 
           title="{!$Label.CustomerInvoice}" renderAs="pdf" language="{!languageCode}">

<html>
<body style="font-family:Arial, Helvetica, sans-serif;font-size:12px">

    <apex:stylesheet value="{!$Resource.RevenovaCSS}"/>

    <!----------------------------------- OPTIONAL SUMMARY PAGE ------------------------------------>
    <!---------------------------------------------------------------------------------------------->

    <apex:outputPanel id="summaryPanel1" rendered="{!AND(isOneCustomer,showCustomHeaderPage)}">
        <apex:include pageName="{!customHeaderPageName}"/>
    </apex:outputPanel>

Here is the controller method that returns the dynamically included page name:

// "HeaderDummy" means no override - you must supply a page to apex:include tag even if not rendered!
public String getCustomHeaderPageName() {
    
    try {
        if(m_tmsDocumentOptions == null) {
            initTDO();
        }
        return m_tmsDocumentOptions.Custom_Header_Page_Name__c != null ? m_tmsDocumentOptions.Custom_Header_Page_Name__c : 'HeaderDummy';
    }
    catch(Exception e) {
        handleException(e,null);
        return 'HeaderDummy';
    }
}

This all works fine when unpackaged. However, when I package the code it fails when attempting to generate the composite Visualforce page. It fails when trying to get the content of the composite page here in the controller that tries to render and save the PDF:

    Blob b = Test.isRunningTest() ? d.getTestContent() : p.getContent();  

The error is very unhelpful:

common.apex.runtime.impl.ExecutionException: Exception common.request.servlet.PageDispatcher$Hack404

To summarize: A dynamically-rendered include with a runtime page name works when unpackaged, but fails when packaged. The dynamically-included second page is always a non-packaged custom page.

Here is the included page:

<apex:page renderAs="pdf">
TEST PAGE
</apex:page>

             

Ideas? Thanks!

6
  • Make sure the dynamic page reference includes the namespace prefix.
    – Phil W
    Jan 4 at 19:46
  • Phil, thanks for responding. The dynamic page included is not packaged. It is custom. So there is no namespace.
    – Dave C
    Jan 4 at 22:33
  • What form of URL are you passing to the PageReference constructor (assuming that's the way you are doing this)? I have a nagging feeling you may need to ensure the unpackaged page name is prefixed with "c__" and it would help to know how you are constructing the page reference and what sort of value you pass to it. Please add via edit.
    – Phil W
    Jan 4 at 22:47
  • Ah I get it.... Good point on the c__. I am retrieving the value from a custom setting field so it is a simple string. I do not have c__ on it. I will try that and let you know. Thanks for your help.
    – Dave C
    Jan 4 at 23:05
  • If you can give an example of the string, plus the code snippet doing the PageReference construction, it would help.
    – Phil W
    Jan 4 at 23:10

1 Answer 1

1

When you are dynamically generating a page reference for a subscriber page, the page name must be prefixed by "c__" which is the "no namespace namespace".

You must log in to answer this question.

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