|
JSP Tag Java Interface
Part:
1
2
3
javax.servlet.jsp.tagext.* Package
javax.servlet.jsp.tagext.* is a Java package defined in J2EE
(I saw it in J2EE 1.3.1). This package contains:
- Tag interface - The base interface required by a tag class to interact
with the JSP tag extension facility.
- IterationTag interface - Extended from Tag interface to support looping
logic within custom tags.
- BodyTag interface - Extended from IterationTag interface to allow
custom tags to evaluate their own body.
- TagSupport class - Dummy implementation of IterationTag interface.
- BodyTagSupport class - Dummy implementation of BodyTag interface.
BodyTag Interface
Since BodyTag interface requires deeper knowledge of JSP in order to evaluate
the tag body properly, we will discuss it later. For now, let's concentrate
on InterationTag interface only. Here is the list of methods required by
InterationTag interface and their calling conditions:
- setPageContext(PageContext pc) - A help method, called before calling doStartTag()
to pass the PageContext object to the tag object.
- setParent(Tag t) - A help method, called before calling doStartTag()
to pass the parent tag object to the current tag object, in case the current tag
is nested within another tag.
- getParent() - A help method, called by child tag classes to access
grand parent tags.
- doStartTag() - An interfacing point, called at the beginning of the process of the tag.
- doAfterBody() - An interfacing point, called after processing the body.
- doEndTag() - An interfacing point, called when ready to leave the process of the tag.
- release() - An interfacing point, called before ending the process of the tag.
The steps used by the JSP tag extension facility to process a custom tag can be summarized
as follows:
- Instanciating the tag object.
- Calling setPageContext() and setParent() of the tag object.
- Processing attributes of the tag. See my other notes on how attribute values are
passed to the tag object.
- Calling doStartTag() of the tag object, which may return a flag to request for skipping
the body to perform a conditional body logic.
- Processing the body of the tag.
- Calling doAfterBody() of the tag object, which may return a flag to request for processing
the body again to perform a loop logic on the body.
- Calling doEndTag() of the tag object.
- Calling release() of the tag object.
(Continued on next part...)
Part:
1
2
3
|