apex:composition

An area of a page that includes content from a second template page. Template pages are Visualforce pages that include one or more <apex:insert> components. The <apex:composition> component names the associated template, and provides body for the template’s <apex:insert> components with matching <apex:define> components. Any content outside of an <apex:composition> component is not rendered.

Use this component to get user input for a controller method that does not correspond to a field on an sObject. Only <apex:inputField> and <apex:outputField> can be used with sObject fields.

See also: <apex:insert>, <apex:define>

Example 

1<!-- Page: composition -->
2<!-- This page acts as the template. Create it first, then the page below.  -->	
3<apex:page>
4	<apex:outputText value="(template) This is before the header"/><br/>
5	<apex:insert name="header"/><br/>
6	<apex:outputText value="(template) This is between the header and body"/><br/>
7	<apex:insert name="body"/>
8</apex:page>
9			
10<!-- Page: page -->
11<apex:page>
12	<apex:composition template="composition">
13		<apex:define name="header">(page) This is the header of mypage</apex:define>
14		<apex:define name="body">(page) This is the body of mypage</apex:define>
15	</apex:composition>
16</apex:page>

The example above renders the following HTML:

1(template) This is before the header<br/>
2(page) This is the header of mypage<br/>
3(template) This is between the header and body<br/>
4(page) This is the body of mypage

Attributes 

Attribute NameAttribute TypeDescriptionRequired?API VersionAccess
renderedStringThis attribute has no effect on the display of this component. If you wish to conditionally display a <apex:component> wrap it inside a <apex:outputPanel> component, and add the conditional expression to its rendered attribute. 10.0global
templateApexPages.PageReferenceThe template page used for this component. For this value, specify the name of the Visualforce page or use merge-field syntax to reference a page or PageReference.Yes10.0global

See Also