【发布时间】:2014-09-15 10:15:35
【问题描述】:
我有一个声明式组件,其中组件 ui 是在运行时根据传递给标签的参数生成的。
现在我想在组件类/托管bean的构造函数中获取属性值。
我第一次加载调用此声明性组件的 jspx 时,DC 的组件类打印出 EL: #{attrs} 为空。这是一个问题,否则我无法初始化表单 UI。
谁能告诉我如何访问传递的属性
【问题讨论】:
标签: java oracle-adf declarative
我有一个声明式组件,其中组件 ui 是在运行时根据传递给标签的参数生成的。
现在我想在组件类/托管bean的构造函数中获取属性值。
我第一次加载调用此声明性组件的 jspx 时,DC 的组件类打印出 EL: #{attrs} 为空。这是一个问题,否则我无法初始化表单 UI。
谁能告诉我如何访问传递的属性
【问题讨论】:
标签: java oracle-adf declarative
我假设您的声明性组件页面上有以下标记?
<af:componentDef var="attrs" ...possible other stuff... >
如果是这样,您还应该定义一个 <af:xmlContent> 标记来保存组件的可能参数。示例:
<attribute>
<attribute-name>customLabel</attribute-name>
<attribute-class>java.lang.String</attribute-class>
</attribute>
这是一个简单(完整)的例子:
<af:componentDef var="attrs" componentVar="component">
<af:panelGroupLayout id="time" layout="horizontal">
<af:outputText id="ot1" label="#{attrs.customLabel}"/>
</af:panelGroupLayout>
<af:xmlContent>
<component xmlns="http://xmlns.oracle.com/adf/faces/rich/component">
<display-name>weirdLabel</display-name>
<attribute>
<attribute-name>customLabel</attribute-name>
<attribute-class>java.lang.String</attribute-class>
</attribute>
<component-extension>
<component-tag-namespace>component</component-tag-namespace>
<component-taglib-uri>http://www.example.com/components</component-taglib-uri>
</component-extension>
</component>
</af:xmlContent>
</af:componentDef>
因此,获取#{attrs.customLabel} 的 EL(在您的组件 bean 中)应该会给您正确的值。
【讨论】: