function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Scott.MScott.M 

Dynamic elements not rendering in multi level composition

I have a dynamic visualforce element that I'm attempting to render on a visualforce page that has two levels of <apex:composition> tags. The element renders fine if I just use one composition. it doesn't render if I use two levels. It seems to me like this is a bug in salesforce. Any insight would be helpful. Here's the simplest version of the issue I'm seeing: 

 

I have one controller named SimpleController used by all the pages and it's source is the following:

 

public class SimpleController {

    public Component.Apex.OutputText dynamictest {get; set;} 
    public PageReference pageRef {get; set;} 
    
    public SimpleController(){
        this.pageRef = Page.SimpleComposition;
        this.dynamictest = new Component.Apex.OutputText();
        this.dynamictest.value = 'This is the dynamic output text';        
    }
    

}

It sets up the a page reference to the page that will be the composition included in the first page name MainPage that has the following source:

 

<apex:page controller="SimpleController">
	<apex:composition template="{!pageRef}" />
</apex:page>

All this page does is output the template from pageRef. From the controller you can see that the template is the visualforce page SimpleComposition which has the following source:

 

<apex:page controller="SimpleController">

	<apex:composition template="SimpleTemplate">
		<apex:define name="dynTest">
			This is a simple composition<br />
			<apex:dynamicComponent componentValue="{!dynamictest}" rendered="true"/>
				
		</apex:define>
	</apex:composition>

</apex:page>

 

 And this is a compostion of the template named SimpleTemplate and it has the following source: 

 

 

<apex:page controller="SimpleController">
	
	
	This is the simple template <br />
	<apex:insert name="dynTest" />

</apex:page>

 

 

This is the expected result when viewing MainPage:

 

This is the simple template 
This is a simple composition

 

This is the dynamic output text

 

This is the actual result :

 

This is the simple template 
This is a simple composition

 

No errors, no indication that anything went wrong. Just no rendering of the dynamic element. If I go to the SimpleComposition page directly I get the expected result.