Enterprise Java

Referring to ADF Faces component in EL expression

EL expressions are commonly used to specify attribute values of ADF Faces components on our page. It is interesting to know that we can use component keyword to refer to the component instance for which the EL expression is being evaluated. This is slightly similar to this in Java.

For example, in the following snippet the button’s hint is evaluated as the button’s text value and its visible attribute is going to be returned by a backing bean method accepting the component as a parameter:

<af:button text="#{theBean.buttonText}" id="b1"
 shortDesc="#{component.text}" visible="#{theBean.isVisible(component)}"/>

The backing bean method may look like this:

  public boolean isVisible(UIComponent button)
  {
    //Do something with the button
    ((RichButton) button).setIcon("images/awesomeIcon.jpg");


    //check button's attributes
    if (button. ...) 
      return true;
     else
      return false;

  }

This technique could be quite useful when it comes to rendering components inside some iterator (or list view or table, etc.) and we need to evaluate component’s attribute value dynamically depending on the exact component instance.

That’s it!

Published on Java Code Geeks with permission by Eugene Fedorenko , partner at our JCG program. See the original article here: Referring to ADF Faces component in EL expression

Opinions expressed by Java Code Geeks contributors are their own.

Eugene Fedorenko

I am a Senior Architect at Flexagon focusing on ADF and many other things.
Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

0 Comments
Inline Feedbacks
View all comments
Back to top button