taglib"

From Documentation
m
m (correct highlight (via JWB))
 
(7 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
{{ZUMLReferencePageHeader}}
 
{{ZUMLReferencePageHeader}}
  
 +
'''Syntax:'''
 +
<?tablib uri="''myURI''" prefix="''my''"?>
  
<source lang="xml" >
+
This directive is used to load a <code>taglib</code> file, which defines a set of static methods that can be used in EL expressions (so called EL functions).  
<?tablib uri="myURI" prefix="my"?>
 
</source>
 
 
 
This directive is used to load a <tt>taglib</tt> file, which defines a set of static methods that can be used in EL expressions.  
 
  
The syntax of a taglib document is described in the subsection:
+
For example, we could load the functions defined in the built-in TLD files identified as [[ZUML Reference/EL Expressions/Core Methods|http://www.zkoss.org/dsp/web/core]], and then use [[ZUML Reference/EL Expressions/Core Methods/l|the l function]].
{{ZKDevelopersReferenceHeadingToc}}
 
 
 
In the following example, we loads functions defined in the built-in TLD files identified as [[ZUML Reference/EL Expressions/Core Methods|http://www.zkoss.org/dsp/web/core]], which is the standard methods, and then use the [[ZUML Reference/EL Expressions/Core Methods/l|l function].
 
  
 
<source lang="xml" >
 
<source lang="xml" >
Line 20: Line 15:
 
</source>
 
</source>
  
'''Tip''': ZK searches all TLD files defined in the <tt>/metainfo/tld/config.xml</tt> file from the classpath. If you want ZK to load your custom TLD files, add them to class path and then specify the following content in the <tt>/metainfo/tld/config.xml</tt> file.
+
If you want to load a TLD file from your Web application, you can specify the path directly. For example, suppose you have a custom TLD at <code>/WEB-INF/tld/my.tld</code>, then you could specify it as follows.
<tt>
 
<taglib>
 
    <taglib-uri>http://your-domain.com/your-path</taglib-uri>
 
    <taglib-location>/the/path/of/your/tld/file</taglib-location>
 
</taglib>
 
</tt>
 
 
 
 
 
 
 
If you want to load a TLD file from your Web application, you can specify the path as follows.
 
  
 
<source lang="xml" >
 
<source lang="xml" >
 
  <?taglib uri="/WEB-INF/tld/my.tld" prefix="my"?>
 
  <?taglib uri="/WEB-INF/tld/my.tld" prefix="my"?>
 +
<listbox>
 +
    <listitem label="${each.name}" forEach="${my:getCustomers()}"/>
 +
        <!-- assume there is a function called getCustomers -->
 +
</listbox>
 
</source>
 
</source>
  
'''Note'''
+
The syntax of a taglib document is described in the subsection:
: taglib in zk aims to support EL functions only. It can't support tag from other library, such as spring security directly. There is a work around, you may use jsp to use tag from other library, and then use ZK-jsp to use it.
+
{{ZUMLReferenceHeadingToc}}
: Please refer to [http://docs.zkoss.org/wiki/ZK/How-Tos/Concepts-and-Tricks#How_to_access_static_member_field_of_a_class_in_zul_without_zscript How to access static member field of a class in zul without zscript] and [http://docs.zkoss.org/wiki/Integrate_with_JSF%2C_JSP_and_Others Integrate with JSF, JSP and Others]
 
  
== uri ==
+
= uri =
  
<source lang="xml" >
+
[Required][EL is ''not'' allowed]
[Required][EL is ''not'' allowed]
 
</source>
 
  
A URL of the <tt>taglib</tt> file. Unlike other URL and URI, it doesn't interpret ~ or * specially. And, the page and the <tt>taglib</tt> files it references must be in the same Web application.
+
A URL of the <code>taglib</code> file. Unlike other URL and URI, it doesn't interpret ~ or * specially. And, the page and the <code>taglib</code> files it references must be in the same Web application.
  
== prefix ==
+
= prefix =
  
<source lang="xml" >
+
[Required]
[Required]
 
</source>
 
  
A prefix used to identify functions defined in this <tt>taglib</tt> file. The prefix could be any non-empty string.
+
A prefix is used to identify functions defined in this <code>taglib</code> file. The prefix could be any non-empty strings.
  
==Version History==
+
=Version History=
  
 
{| border='1px' | width="100%"
 
{| border='1px' | width="100%"

Latest revision as of 13:28, 19 January 2022

Syntax:

<?tablib uri="myURI" prefix="my"?>

This directive is used to load a taglib file, which defines a set of static methods that can be used in EL expressions (so called EL functions).

For example, we could load the functions defined in the built-in TLD files identified as http://www.zkoss.org/dsp/web/core, and then use the l function.

 <?taglib uri="http://www.zkoss.org/dsp/web/core" prefix="c"?>
 <window title="${c:l('my.title')}">
 ...
 </window>

If you want to load a TLD file from your Web application, you can specify the path directly. For example, suppose you have a custom TLD at /WEB-INF/tld/my.tld, then you could specify it as follows.

 <?taglib uri="/WEB-INF/tld/my.tld" prefix="my"?>
<listbox>
    <listitem label="${each.name}" forEach="${my:getCustomers()}"/>
        <!-- assume there is a function called getCustomers -->
</listbox>

The syntax of a taglib document is described in the subsection:

Subsections:


uri

[Required][EL is not allowed]

A URL of the taglib file. Unlike other URL and URI, it doesn't interpret ~ or * specially. And, the page and the taglib files it references must be in the same Web application.

prefix

[Required]

A prefix is used to identify functions defined in this taglib file. The prefix could be any non-empty strings.

Version History

Version Date Content
     



Last Update : 2022/01/19

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