From Documentation

Jump to: navigation, search



You have two ways to import java methods to EL. Through xel-method, or taglib.

Through xel-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')}"/>

In example above, Class.forName("java.util.List") is called.

Through taglib

To import EL functions from TLD(TagLib Definition)[1] files, you could use a processing instruction called taglib as follows.[2]

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

In the following example, we use function l to get the property app.title defined in resource file.[3]

<window title="${c:l('app.title')}">


Inside core.dsp.tld, you can find the definition of function l.

<function>
	<name>l</name>
	<function-class>org.zkoss.xel.fn.CommonFns</function-class>
	<function-signature>java.lang.String getLabel(java.lang.String)</function-signature>
	<description>
		Returns the label of the specified key.
	</description>
</function>


Notes

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.
  1. http://java.sun.com/products/jsp/tutorial/TagLibraries17.html
  2. http://www.zkoss.org/dsp/web/core is not really an URL. It's a key to tell ZK loader to find the tld file inside ZK jar files.
  3. It's a way to retrieve resources for different locale. Please refer to Chapter. Internationalization




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