Creating and Editing Tags
See Also
A tag consists of a tag signature plus a tag handler, which is a body of Java
code. The IDE generates skeleton code for tag handlers based on specifications
you supply in the Tag Customizer dialog box. You then edit the tag handler code
directly to insert the logic that implements the features of the tag.
To create a tag:
- In the Filesystems window, right-click the tag library descriptor's (TLD)
node.
- Choose Add Tag from the contextual menu. The Add New Tag dialog box appears.
- In the Add New Tag dialog box, edit the tag. See Tag Customizer
Fields for more information.
- Click OK to have the changes take effect immediately and to dismiss the
Add New Tag dialog box.
To edit a tag:
- In the Filesystems window, right-click the tag and choose Customize from
the contextual menu.
- In the Tag Customizer dialog box, edit the tag. See Tag
Customizer Fields for more information.
- Click OK to have the changes take effect immediately and to dismiss the
Tag Customizer. Click Apply to apply the changes without dismissing the Tag
Customizer.
Once a Tag Customizer is displayed, it tracks the selection and shows the properties
of any tag that is selected.
Tag Customizer Fields
Fields on the General page include:
- Tag Name. Specifies the unique tag element name. The tag element
name must conform to Java language naming standards. Tag element names have
the same restrictions as Java identifiers. They cannot start with a digit,
cannot contain spaces, and cannot contain special characters such as !. #,
or +. Multibyte tag names are allowed. However, tag libraries that contain
such tag names might not execute well in some web servers.
- Display Name. A display name is a short name intended to be displayed
by tools.
- Tag Class Name. Specifies the class name used for the generated file.
If the Tag Class Name field is blank, tabbing out of the Tag Name field fills
it in automatically. The tag class name must conform to Java language naming
standards and must be a valid Java classname.
- Package Name. Specifies the name of the Java package for the generated
tag handler classes. The default value is the name of the tag library.
- Body Content. Specifies the type of content that is to occur in the
body of the tag. Options in the combo-box are JSP, that is, the body
of the tag contains elements using the JSP syntax, empty, that is,
the body is empty, and tagdependent, that is, the body is interpreted
by the tag handler itself and can be written in a "language" other
than the JSP syntax. The default value is JSP.
- Description. Specifies descriptive information about intended uses
for the tag.
- Example. Provides an informal description of an example of the use
of the tag.
Fields on the Code Generation page include:
- Implements Interface. Specifies which interface the tag implements.
The use of interfaces simplifies making an existing Java object a tag handler.
Choices in the combo-box include:
Tag
, which defines the basic methods needed in all tag
handlers
IterationTag
, which provides the additional method doAfterBody(),
invoked for the reevaluation of the body of the tag
BodyTag
, which extends IterationTag
with two
new methods for when the tag handler wants to manipulate the tag body:
setBodyContent
and doInitBody
- Extends Support Class. Support classes can be used as base classes
when implementing the
Tag
or IterationTag
interfaces.
Choices in the combo-box include:
TagSupport
, a utility class that adds additional convenience
methods including getter methods of the properties in the Tag
interface. TagSupport
has one static method that is included
to help coordinate among cooperating tags.
BodyTagSupport
, a class that implements the BodyTag interface
and adds additional convenience methods.
- OtherClass, which if selected, activates the Other Support Class field.
- Other Support Class. If not extending the
TagSupport
or BodyTagSupport
classes, use the Other Support Class field
to specify the base class that the tag extends.
- Implements TryCatchFinally Interface. The
TryCatchFinally
interface is a "mix-in" interface that can be added to a class implementing
the Tag
, IterationTag
, or BodyTag
interfaces.
The TryCatchFinally
interface provides two new methods: doCatch(Throwable)
and doFinally()
.
- Find Parent. Indicates that the generated tag handler is to contain
code to find the parent, that is, the enclosing, tag, whose type is determined
by the Of Type property. The parent's tag handler instance, if found, is placed
in the variable specified by the As Variable property. If checked, Find Parent
enables the Of Type and As Variable properties. The default value is unchecked.
- Of Type. Specifies the Java class type of the parent. Select a class
name from the combo box, or type in another choice. The default is an empty
string.
- As Variable. Specifies the variable name that is to be used for the
parent. The default value is <type>_parent where <type>
is the value from Of Type.
Fields on the Icons page include:
- Small Icon. Specifies the name of a file containing a small (16 x
16) icon image for use by tools.
- Large Icon. Specifies the name of a file containing a large (32 x
32) icon image for use by tools.
For more information about creating and using custom tags, see JavaServer
Pages Specification available at http://java.sun.com/products/jsp.
Legal Notices
See Also