站内搜索: 请输入搜索关键词
当前页面: 在线文档首页 > The J2EE 1.4 Tutorial

Defining the Custom Component Tag in a Tag Library Descriptor - The J2EE 1.4 Tutorial

Defining the Custom Component Tag in a Tag Library Descriptor

To define a tag, you declare it in a TLD. The web container uses the TLD to validate the tag. The set of tags that are part of the HTML render kit are defined in the html_basic TLD.

The custom tags area and map are defined in bookstore.tld. The bookstore.tld file defines tags for all the custom components and the custom validator tag described in Creating a Custom Tag.

All tag definitions must be nested inside the taglib element in the TLD. Each tag is defined by a tag element. Here is part of the tag definition of the map tag:

<tag>
  <name>map</name>
  <tag-class>taglib.MapTag</tag-class>
  <attribute>
    <name>binding</name>
    <required>false</required>
    <rtexprvalue>false</rtexprvalue>
    <type>String</type>
  </attribute>
  <attribute>
    <name>current</name>
    <required>false</required>
    <rtexprvalue>false</rtexprvalue>
    <type>String</type>
  </attribute>
  <attribute>
    <name>id</name>
    <required>false</required>
    <rtexprvalue>false</rtexprvalue>
    <type>String</type>
  </attribute>
  ...
</tag> 

At a minimum, each tag must have a name (the name of the tag) and a tag-class (the tag handler) attribute. For more information on defining tags in a TLD, please consult the Tag Library Descriptors section of this tutorial.