evaluator

From Documentation
Revision as of 06:10, 17 May 2022 by Hawk (talk | contribs) (→‎name)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Syntax:

<?evaluator [name="..."] [class="..."] [import="..."]?>

It specifies how to evaluate XEL expressions.

name

[Optional][Default: none][Case insensitive]

The name of the implementation used to evaluate the XEL expressions. There are two ways to specify the implementation. One is the name attribute. The other is the class attribute.

For example, if you want to use MVEL[1], you can specify the name as follows.

 <?evaluator name="mvel"?>
 <window id="w" title="MVEL Demo">
     ${new org.zkoss.zul.Textbox().setParent(w)}
 </window>

Here is a list of built-in implementations:

Name
Class / Description
default org.zkoss.xel.el.ELFactory

The default implementation. It is based on ZK Commons EL (zcommons-el.jar), which is a performance enhancement version of Apache Commons EL.

zel org.zkoss.xel.zel.ELFactory

The implementation based on The ZK EL Library(zel.jar), which supports new features seen in Unified Expression Language 2.2 such as method calls and l-value.

''[Since ZK 6, ZK uses this evaluator as the default one.]''
mvel org.zkoss.zkmax.xel.mvel.MVELFactory

The implementation based on MVEL, http://mvel.codehaus.org.

''[available only if zkmax.jar is loaded]''
ognl org.zkoss.zkmax.xel.ognl.OGNLFactory

The implementation based on OGNL, http://www.ognl.org.

''[available only if zkmax.jar is loaded]''
commons-el org.zkoss.zkmax.xel.el.ApacheELFactory

The implementation that is based on Apache Commons EL, org.apache.commons.el.ExpressionEvaluatorImpl.

''[available only if zkmax.jar is loaded]''
japser-el org.zkoss.zkmax.xel.el21.ApacheELFactory

The implementation that is based on Apache JSP 2.1 EL, org.apache.el.ExpressionFactoryImpl.

''[available only if zkmax.jar is loaded]''

You can provide additional implementation by the use of the class attribute, as described in the following section. The class must implement the ExpressionFactory interface. Or, you can specify the following content in metainfo/xel/config.xml.

 <config>
     <xel-config>
         <evaluator-name>Super</evaluator-name><!-- case insensitive -->
         <evaluator-class>my.SuperEvaluator</evaluator-class>
     </xel-config>
 </config>

Notes

  1. MVEL is a powerful expression language. Refer to http://mvel.codehaus.org/ for more information.

class

[Optional][Default: dependind on how xel-config is specified]

The implementation used to evaluate the XEL expressions. In addition to the name attribute, you can specify the class directly. For example, you can use MVEL by specifying class as follows.

 <?evaluator class="org.zkoss.zkmax.xel.mvel.MVELFactory"?>
 <window id="w" title="MVEL Demo">
     ${new org.zkoss.zul.Textbox().setParent(w)}
 </window>

import

[Optiona][Default: what are defined in taglib]

Specifies a list of classes separated with comma to import for evaluating the expression in this page. For example, with MVEL:

 <?evaluator class="org.zkoss.zkmax.xel.mvel.MVELFactory"
 import="org.zkoss.zul.Datebox,org.zkoss.zul.Combobox"?>
 <window id="w" title="MVEL Demo">
     ${new Datebox().setParent(w)}
 </window>

Notice that not all evaluators support the import of classes. For example, all EL-based the evaluators, including the system default one, do not support it. In other words, the import attribute is meaningless to them (since they don't have the concept of instantiation).

In addition, the class's names specified in the import attribute must be a fully qualified name (including the package's name). In other words, it ignores the classes imported by the import directive.

Version History

Version Date Content
6.0.0 September 2011 Support those new features seen in Unified Expression Language 2.2 such as method calls and l-value.



Last Update : 2022/05/17

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