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:
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!
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!
No comments:
Post a Comment
Post Comment