e martë, 19 qershor 2007

Components to make up Tag Library.

1) Tag Handler Class -- holds logic for the tag implementation
- need to implement Tag interface, can be achieved by extending TagSupport or BodyTagSupport class.
- some important methods
--- doStartTag() -- basic method called for tag found in JSP, called for non-attribute tags the logic can be implemented over here.
--- doEndTag()
--- can have setter/getter methods of the tag attributes, so whenever an attribute is passed from a JSP it calls setter method to set the value in Tag handler class and later be used by doStartTag() or other business/logic methods.

2) Tag Library Descriptor File -- maps XML element names to the tag implementations
- maps tag to tag handler class
- defines tag attributes (required/optional)

3) JSP file -- uses the tag
- define the taglib directive to point to tag library descriptor file.
--- <%@ taglib uri="abc\def\xyz.tld" prefix="xyz" %>
---

Nuk ka komente: