JSP tags are responsible for rendering HTML pages based on the attributes
of the tag. If you want to create a new JSP tag, do the following:
- Create a Java(TM) class that inherits from StrutsTagSupport
class. The class StrutsTagSupport is in the com.ibm.btt.struts.taglib.html.
package.
- Add the required attributes to the class and implement the setters
for these new attributes according to the following convention:
public void setNewAttributeName(String newAttributeValue)
where the "N" in NewAttributeName must be an uppercase letter.
- Implement the doStartTag and doEndTag methods, adding the corresponding
logic associated with the open and close tag (such as <btt:newTag> and </btt:newTag>).
- Add the definition of the new tag into the tag library
descriptor (you might choose to create a new tag library descriptor or update
the one provided with the product, which is btt-html.tld). The
following information must be added to the TLD file:
<tag>
<name>newTagName</name>
<tagclass>fullQualifiedNewClassName</tagclass>
<bodycontent>EMPTY</bodycontent>
<info>New tag description</info>
<attribute>
<name>attributeName1</name>
<required>true</required>
</attribute>
<attribute>
<name>attributeName2</name>
<required>false</required>
</attribute>
</tag>
where:
- name is the value used in the JSP (<btt:newTagName>)
- tagClass is the class implementing the tag behavior
- bodyContent provides information about the contents of the tag.
Following are the possible values:
- EMPTY means that there are no contents between the open tag and the close
tag
- TAGDEPENDENT means that the contents between the open tag and the close
tag will be evaluated by the tag implementation itself. It may be empty, too.
- JSP means that the contents between the open tag and the close
tag will be evaluated by some other tag of the JSP. It may be empty, too.
- info is just a description
All the attributes must be declared here, including the ones inherited
from the parent classes. These are the attributes that will be accepted by
the JSP during the development process, and the required parameter
is used by the tooling facilities to give an error if a mandatory attribute
is missing.