0

i have a declarative component in which the component ui is generated at run time based on the parameters passed to the tag.

now i want to get the attribute values in the constructor of the component class/Managed bean.

the first time i load the jspx where this declarative component is called, the component class of the DC prints that the EL: #{attrs} is null. This is an issue as without that i cannot initialize the form UI.

Can anyone tell me how to access the attributes that are passed

Jon Heller
  • 34,999
  • 6
  • 74
  • 132
Fr_nkenstien
  • 1,923
  • 7
  • 33
  • 66

1 Answers1

0

I assume you have the following tag on your declarative component page?

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

If so, you should also have defined a <af:xmlContent> tag which holds the possible params of your component. Example:

<attribute>
  <attribute-name>customLabel</attribute-name>
  <attribute-class>java.lang.String</attribute-class>
</attribute>

Here is a simple (complete) example:

<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>

So getting the EL (in you component bean) of #{attrs.customLabel}should give you the correct value.

User404
  • 2,152
  • 2
  • 27
  • 35