Home   Single Page

The EL Expressions

Like JSP, you could use EL expressions in any part of ZUML pages, except the names of attributes, elements and processing instructions.

EL expressions use the syntax ${expr}. For example,

<element attr1=”${bean.property}”.../>
${map[entry]}
<another-element>${3+counter} is ${empty map}</another-element>

Tip: empty is an operator used to test whether a map, a collection, an array or a string is null or empty.

Tip: map[entry] is a way to access an element of a map. In other words, it is the same as map.get(entry) in Java.

When an EL expression is used as an attribute value, it could return any kind of objects as long as the component accepts it. For example, the following expression will be evaluated to a Boolean object.

<window if="${some > 10}">

Tip: The + operator in EL is arithmetic. It doesn't handle string catenations. If you want to catenate strings, simple use "${expr1} is added with ${expr2}".

Standard implicit objects, such as param and requestScope, and ZK implicit objects, such as self and page, are supported to simplify the use.

<textbox value="${param.who} does ${param.what}"/>

To import a method, you can use a processing instruction called the xel-method as follows.

<?xel-method prefix="c" name="forName"
    class="java.lang.Class"    
    signature="java.lang.Class forName(java.lang.String)"?>    
<textbox value="${c:forName('java.util.List')}"/>

To import EL functions from TLD files, you could use a processing instruction called taglib as follows.

<?taglib uri="http://www.zkoss.org/dsp/web/core" prefix="c" ?>

The Developer's Reference provides more details on EL expressions. Or, you might refer to JSP 2.0 tutorials or guides for more information about EL expressions.