【问题标题】:not able to get passed attributes in declarative component managed bean in Constructor in Oracle adf无法在 Oracle adf 的构造函数中的声明性组件托管 bean 中获取传递的属性
【发布时间】:2014-09-15 10:15:35
【问题描述】:

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

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

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

谁能告诉我如何访问传递的属性

【问题讨论】:

    标签: java oracle-adf declarative


    【解决方案1】:

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

    <af:componentDef var="attrs" ...possible other stuff... >
    

    如果是这样,您还应该定义一个 &lt;af:xmlContent&gt; 标记来保存组件的可能参数。示例:

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

    【讨论】:

    • 我得到了这么多,但不是在构造函数执行期间。那时我得到的值为 null :( 任何想法。
    猜你喜欢
    • 1970-01-01
    • 2013-07-04
    • 2016-11-07
    • 1970-01-01
    • 2017-02-07
    • 2013-06-08
    相关资源
    最近更新 更多