Visualforce 页面中的 <apex: dynamicComponent>

17 Mar 2025 | 阅读 2 分钟

<apex: dynamicComponent> 是一个组件标签,用于我们的动态 Apex 组件。 它充当占位符,并具有一个必需的参数,即 componentValue。 componentValue 是返回动态组件的 Apex 方法的名称。

以下是一些没有动态 Apex 表示形式的组件:

  • <apex: attribute>
  • <apex: component>
  • <apex: componentBody>
  • <apex: composition>
  • <apex: define>
  • <apex: dynamicComponent>
  • <apex: include>
  • <apex: insert>
  • <apex: param>
  • <apex: variable>

<apex: dynamicComponent> 具有以下属性:

1. componentValue

componentValue 是一个 UIComponent 类型的属性,用于指定返回动态 VF 组件的 Apex 方法的名称。

语法

2. id

id 是一个 string 类型的属性,即一个唯一的标识符,允许自定义组件定义中的其他组件引用此组件。

语法

3. invokeAfterAction

id 是一个 Boolean 类型的属性,用于指定是否在调用页面的或 submit 的 action 方法之后调用 componentValue 的 Apex 方法。

语法

4. rendered

rendered 是一个 Boolean 类型的属性,用于指定是否需要在页面上渲染此组件。 boolean 值 true 被设置为此属性的默认值。

语法

让我们举个例子来了解如何在 VF 页面上使用此组件

ApexDynamicComponentExample.vfp

DynamicComponentController.apxc

输出

apex: dynamicComponent in Visualforce Page
下一个主题Google 云平台