This section describes how to implement a JSP tag handler and how to use it in the UNICOM® Digital Transformation Toolkit (UDTT™) framework.
Implementing a JSP tag handler
After the new JSP tag for a widget has been generated into a JSP file, it still requires a tag handler to generate the dynamic HTML content for this new JSP tag at runtime.
A technical developer does not need not to implement JSP tag handler from scratch. He can implement the tag handler by extending the UDTT base classes. UDTT provides the following two abstract tag handlers for a technical developer to extend.
com.ibm.btt.dojo.tag.AbstractSimpleTag
Is provided for a handler with handles tag that do not contain sub-tags or inner content, such as button or label tag.
When you extend the com.ibm.btt.dojo.tag.AbstractSimpleTag class, the following two methods must be overridden.
protected void initAttributes()
Tag handler needs to put DOJO widget type the tag corresponding to into attributes in this method.
The method is used for subclass to inject other JavaScript code or generate hidden HTML fields after dojo code is generated in UDTT.
com.ibm.btt.dojo.tag.AbstractBodyTag
The com.ibm.btt.dojo.tag.AbstractBodyTag class is provided for handler which handles tag contains sub-tags or inner content. For example, table tag may have nested column tags to describe each column in table.
com.ibm.btt.dojo.tag.AbstractBodyTag handles the logic of generating content for sub-tags, so extending the com.ibm.btt.dojo.tag.AbstractBodyTag class is similar to extending the com.ibm.btt.dojo.tag.AbstractSimpleTag class. Both the initAttributes() and the getTagName() methods must be overridden.
In addition to the protected void beforeGenerateTag(StringBuffer buffer) and the protected void afterGenerateTag(StringBuffer buffer) methods, the protected void afterGenerateStartTag(StringBuffer buffer, Map<String, String> attributes) method is also provided for a technical developer to extend.
As indicated by name, the protected void beforeGenerateTag(StringBuffer buffer) method is used for subclass to inject the code after AbstractBodyTag generating start tag.
Registering a JSP tag handler
To enable the implemented JSP tag, handler can be used by UDTT at runtime. A technical developer must create a new JSP lib file to support that tags that have been created for new widgets. The file follows standard JSP tag library schema. See http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd for more information.