<apex: composition> Component in Visualforce Page

The <apex: composition> is another important component used to define an area of the page that includes content from a second template page. The template page includes one or more <apex: insert> components. The <apex: composition> component names the associated template and provides a body for the template's <apex: insert> components with matching <apex: define> components. Any content outside of an <apex: composition> component is not rendered.

We use this component to get user input from the controller method that doesn't correspond to a field on a sObject field.

The <apex: composition> component has the following attributes:

1. rendered

The rendered is a string-type attribute used for rendering the component. However, the rendered attribute does not affect the display of this component.

Syntax:

2. template

The template is an "ApexPages.PageReference" type used for specifying the template page used for this component. The name of the apex page or PageReference is used as a value for this attribute.

Syntax:

Let's take an example to understand how we can use this component on the Visualforce page:

ApexCompositionExample.vfp

ApexInsertExample.vfp

Output

apex: composition Component in Visualforce Page




Latest Courses