ibm.com/developerWorks
Presented by developerWorks, your source for great tutorials
Section 3. Step by step Custom Tag example (TagLib)
Using the XDoclet?s webdoclet task to create
Custom Tag TLDsClass level JavaDoc tags for
Custom Tags
Just like before, the mappings are quite natural. The first step is to define the jsp tag
using the jsp.tag and passing the name of the custom tag as follows:
* @jsp.tag name="BasicTag"
This code generates the following in the TLD file:
BasicTag
tomcatbook.customtag.BasicTag
...
Remember that XDoclet uses the JavaDoc API to get the full class name of the custom
tag handler. Next, you define any variables that you want available to the JSP pages
that use your custom tag. For this example, you defined three variables. One of the
variables can be used after the begin tag, one after the end tag only, and one only
inside the body, as shown here:
* @jsp.variable name given="currentIter"
*
class="java.lang.Integer" scope="NESTED"
* @jsp.variable name given="atBegin"
*
class="java.lang.Integer" scope="AT_BEGIN"
* @jsp.variable name given="atEnd"
*
class="java.lang.Integer" scope="AT_END"
A side benefit of XDoclet it that it keeps everything that makes of this Custom tag
together in one file. In addition, it is great for documenting what makes up this Custom
tag. Imagine not using XDoclet, you would have to go spelunking through a long TLD
file looking for the right entries (the
struts html.tld
file is 3000 lines long!) to see what
variables this tag defined.
This code generates the following in the TLD file within the basic tag definition:

currentIter
Page 22 of 49
Enhance J2EE component reuse with XDoclets






footer




 

 

 

 

 Home | About Us | Network | Services | Support | FAQ | Control Panel | Order Online | Sitemap | Contact

j2ee web hosting

 

Our partners: PHP: Hypertext Preprocessor Best Web Hosting Java Web Hosting Jsp Web Hosting Cheapest Web Hosting

Visionwebhosting.net Business web hosting division of Web Design Plus. All rights reserved