Note: This release is in preview. Features described here don’t become generally available until the latest general availability date that Salesforce announces for this release. Before then, and where features are noted as beta, pilot, or developer preview, we can’t guarantee general availability within any particular time frame or at all. Make your purchase decisions only on the basis of generally available products and features.

apex:dynamicComponent

This tag acts as a placeholder for your dynamic Apex components. It has one required parameter—componentValue—which accepts the name of an Apex method that returns a dynamic component.

The following Visualforce components do not have dynamic Apex representations:
  • <apex:attribute>
  • <apex:component>
  • <apex:componentBody>
  • <apex:composition>
  • <apex:define>
  • <apex:dynamicComponent>
  • <apex:include>
  • <apex:insert>
  • <apex:param>
  • <apex:variable>

Example

1<apex:page controller="SimpleDynamicController">
2    <apex:dynamicComponent componentValue="{!dynamicDetail}" />
3</apex:page>
4
5/* Controller */
6public class SimpleDynamicController {
7
8    public Component.Apex.Detail getDynamicDetail() {
9        Component.Apex.Detail detail = new Component.Apex.Detail();
10        detail.expressions.subject = '{!acct.OwnerId}';
11        detail.relatedList = false;
12        detail.title = false;
13        return detail;
14    }
15
16    // Just return the first Account, for example purposes only
17    public Account acct {
18        get { return [SELECT Id, Name, OwnerId FROM Account LIMIT 1]; }
19    }
20}

Attributes

Attribute Name Attribute Type Description Required? API Version Access
componentValue UIComponent Accepts the name of an Apex method that returns a dynamic Visualforce component. Yes 22.0
id String An identifier that allows the attribute to be referenced by other tags in the custom component definition. 22.0 global
invokeAfterAction Boolean A Boolean value that, when true, specifies that componentValue's Apex method is called after the page's or submit's action method is invoked. 31.0
rendered Boolean A Boolean value that specifies whether the component is rendered on the page. If not specified, this value defaults to true. 22.0