Import Java Methods

From Documentation

Stop.png This documentation is for an older version of ZK. For the latest one, please click here.

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"
    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="" 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-signature>java.lang.String getLabel(java.lang.String)</function-signature>
		Returns the label of the specified key.


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.
  2. 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

Last Update : 2022/01/19

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