无法在Oracle adf中的构造函数中获取声明性组件托管bean中的传递属性

时间:2014-09-15 10:15:35

标签: java oracle-adf declarative

我有一个声明性组件,其中组件ui是在运行时根据传递给标记的参数生成的。

现在我想在组件类/ Managed bean的构造函数中获取属性值。

第一次加载调用此声明性组件的jspx时,DC的组件类打印EL: #{attrs}为空。这是一个问题,因为没有我无法初始化表单UI。

任何人都可以告诉我如何访问传递的属性

1 个答案:

答案 0 :(得分:0)

我假设您的声明性组件页面上有以下标记?

<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中)应该会给你正确的值。