Import Java Methods
From Documentation
Revision as of 08:26, 12 July 2010 by Maya001122 (talk | contribs) (Created page with '{{ZKDevelopersGuidePageHeader}} You have two ways to import java methods to EL. Through <tt>xel-method</tt>, or <tt>taglib</tt>. ===Through <tt>xel-method</tt>=== you can use a…')
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"
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.
- ↑ http://java.sun.com/products/jsp/tutorial/TagLibraries17.html
- ↑ 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.
- ↑ It's a way to retrieve resources for different locale. Please refer to Chapter. Internationalization