Import Java Methods"
From Documentation
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…') |
Tmillsclare (talk | contribs) m |
||
Line 23: | Line 23: | ||
</source> | </source> | ||
− | In the following example, we use function <tt>l</tt> to get the property <tt>app.title</tt> defined in resource file.<ref>It's a way to retrieve resources for different locale. Please refer to Chapter. [[Internationalization | Internationalization]]</ref> | + | In the following example, we use function <tt>l</tt> to get the property <tt>app.title</tt> defined in resource file.<ref>It's a way to retrieve resources for different locale. Please refer to Chapter. [[ZK_Developer's_Guide/Advanced_ZK/Internationalization | Internationalization]]</ref> |
<source lang="xml" > | <source lang="xml" > | ||
<window title="${c:l('app.title')}"> | <window title="${c:l('app.title')}"> |
Revision as of 09:28, 6 September 2010
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