EL Expressions"

From Documentation
m
Line 24: Line 24:
 
<window title="${foo.name}: ${foo.version}">
 
<window title="${foo.name}: ${foo.version}">
 
</source>
 
</source>
 +
 +
=Example=
 +
 +
{| border='1px'
 +
! EL Expression !! Result
 +
|-
 +
| ${1 > (4/2)}
 +
| false
 +
|-
 +
| ${100.0 == 100}
 +
| true
 +
|-
 +
| ${'a' < 'b'}
 +
| true
 +
|-
 +
| ${'hip' gt 'hit'}
 +
| false
 +
|-
 +
| ${1.2E4 + 1.4}
 +
| 12001.4
 +
|-
 +
| ${3 div 4}
 +
| 0.75
 +
|-
 +
| ${10 div 4}
 +
| 2
 +
|-
 +
| ${empty param.add}
 +
| true if the request parameter named <tt>add</tt> is null or an empty string
 +
|-
 +
| ${param['mycom.productId']}
 +
| The value of the request parameter named <tt>mycom.productId</tt>
 +
|}
 +
* The example is from [http://download.oracle.com/javaee/1.4/tutorial/doc/JSPIntro7.html JSP Tutorial].
 +
 +
=Difference from Java=
  
 
=Version History=
 
=Version History=

Revision as of 02:59, 25 November 2010

Overview

An EL expressions is an expression enclosed with ${ and }, i.e., the syntax is ${expr}. For example,

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

When an EL expression is used as an attribute value, it could return any kind of objects as long as the attribute allows. For example, the following expressions will be evaluated to boolean and int, respectively.

 <window if="${some > 10}"><!-- boolean -->
   <progressmetter value="${progress}"/><!-- integer -->

If the class does not match, ZK Loader will try to coerce it to the correct one. If failed, an exception is thrown.

Multiple EL expressions could be specified in a single attribute:

<window title="${foo.name}: ${foo.version}">

Example

EL Expression Result
${1 > (4/2)} false
${100.0 == 100} true
${'a' < 'b'} true
${'hip' gt 'hit'} false
${1.2E4 + 1.4} 12001.4
${3 div 4} 0.75
${10 div 4} 2
${empty param.add} true if the request parameter named add is null or an empty string
${param['mycom.productId']} The value of the request parameter named mycom.productId

Difference from Java

Version History

Last Update : 2010/11/25


Version Date Content
     


Last Update : 2010/11/25


Copyright © Potix Corporation. This article is licensed under GNU Free Documentation License.