10.12.2012 Views

The Java EE 5 Tutorial (PDF) - Oracle Software Downloads

The Java EE 5 Tutorial (PDF) - Oracle Software Downloads

The Java EE 5 Tutorial (PDF) - Oracle Software Downloads

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Defining the Custom ComponentTag in aTag Library Descriptor<br />

If your component does not have a renderer associated with it, getRendererType should return<br />

null. In this case, the renderer-type element in the application configuration file should also<br />

be set to null.<br />

Releasing Resources<br />

It’s recommended practice that all tag handlers implement a release method, which releases<br />

resources allocated during the execution of the tag handler. <strong>The</strong> release method of MapTag as<br />

follows:<br />

public void release() {<br />

super.release();<br />

current = null;<br />

styleClass = null;<br />

actionListener = null;<br />

immediate = null;<br />

action = null;<br />

}<br />

This method first calls the UIComponentTag.release method to release resources associated<br />

with UIComponentTag. Next, the method sets all attribute values to null.<br />

Defining the Custom ComponentTag in aTag Library<br />

Descriptor<br />

432<br />

To define a tag, you declare it in a TLD. <strong>The</strong> web container uses the TLD to validate the tag. <strong>The</strong><br />

set of tags that are part of the HTML render kit are defined in the html_basic TLD.<br />

<strong>The</strong> custom tags area and map are defined in bookstore.tld. <strong>The</strong> bookstore.tld file defines<br />

tags for all the custom components and the custom validator tag described in “Creating a<br />

Custom Tag” on page 400.<br />

All tag definitions must be nested inside the taglib element in the TLD. Each tag is defined by a<br />

tag element. Here is part of the tag definition of the map tag:<br />

<br />

map<br />

taglib.MapTag<br />

<br />

binding<br />

false<br />

<br />

<br />

<strong>The</strong> <strong>Java</strong> <strong>EE</strong> 5<strong>Tutorial</strong> • June 2010

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!