First page Back Continue Last page Graphics

Using Expression Language to Conditionally Display Components


Notes:

Using Expression Language (EL)

In JSF, you use a simple expression language (EL) to work with the information you want to present. At run time, a generic expression evaluator returns the value of expressions, automating access to the individual objects and their properties without requiring code. Because any attribute of a component can be assigned a value by using an EL expression, it’s easy to build dynamic, data-driven user interfaces.

Here are some examples of how to use EL:

For the component’s value: At run time, the value of a JSF UI component is determined by its value attribute. Although a component can have static text as its value, typically the value attribute contains an EL expression that the run-time infrastructure evaluates to determine what data to display.

To hide a component when a set of objects you need to display is empty: Use a Boolean-valued expression such as #{not empty ProductList.selectedProducts} in the UI component’s rendered attribute. If the list of selected products in the object named ProductsList is empty, the rendered attribute evaluates to false and the component disappears from the page.

For more information about expression language, see: http://java.sun.com/j2ee/1.4/docs/tutorial/doc/JSPIntro7.html http://www.oracle.com/technology/sample_code/tutorials/jsp20/simpleel.html