evaluator

From Documentation
Revision as of 03:50, 8 July 2010 by Maya001122 (talk | contribs)

The evaluator Directive

 <?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 are 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.

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, ExpressionFactoryImpl.

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

You can provide additional implementations by use of the class attribute, as described in the following section. The class must implement the org.zkoss.xel.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, don't support it. In other words, the import attribute is meaningless to them. Rather, you have to use the taglib directive to import functions.