Import Java Methods"
From Documentation
Tmillsclare (talk | contribs) m |
m (correct highlight (via JWB)) |
||
Line 1: | Line 1: | ||
{{ZKDevelopersGuidePageHeader}} | {{ZKDevelopersGuidePageHeader}} | ||
− | You have two ways to import java methods to EL. Through < | + | You have two ways to import java methods to EL. Through <code>xel-method</code>, or <code>taglib</code>. |
− | ===Through < | + | ===Through <code>xel-method</code>=== |
− | you can use a processing instruction called the < | + | you can use a processing instruction called the <code>xel-method</code> as follows. |
<source lang="xml" > | <source lang="xml" > | ||
Line 13: | Line 13: | ||
</source> | </source> | ||
− | In example above, < | + | In example above, <code>Class.forName("java.util.List")</code> is called. |
− | ===Through < | + | ===Through <code>taglib</code>=== |
− | To import EL functions from TLD(TagLib Definition)<ref>http://java.sun.com/products/jsp/tutorial/TagLibraries17.html</ref> files, you could use a processing instruction called < | + | To import EL functions from TLD(TagLib Definition)<ref>http://java.sun.com/products/jsp/tutorial/TagLibraries17.html</ref> files, you could use a processing instruction called <code>taglib</code> |
as follows.<ref>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.</ref> | as follows.<ref>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.</ref> | ||
Line 23: | Line 23: | ||
</source> | </source> | ||
− | In the following example, we use function < | + | In the following example, we use function <code>l</code> to get the property <code>app.title</code> 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')}"> | ||
Line 29: | Line 29: | ||
− | Inside core.dsp.tld, you can find the definition of function < | + | Inside core.dsp.tld, you can find the definition of function <code>l</code>. |
<source lang="xml" > | <source lang="xml" > | ||
<function> | <function> |
Latest revision as of 10:36, 19 January 2022
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