IBM WebSphere Multichannel Bank Transformation Toolkit, Version 7.1

Implementing and registering a JSP tag handler

This section describes how to implement a JSP tag handler and how to use it in the IBM® WebSphere® Multichannel Bank Transformation Toolkit 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 WebSphere Multichannel Bank Transformation Toolkit base classes. WebSphere Multichannel Bank Transformation Toolkit 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.
protected void initAttributes(){
		super.initAttributes();
		attributes.put("dojoType", "com.ibm.btt.dijit.Account");
}
protected String getTagName()
Tag handler needs to return HTML tag name of the DOJO widget in this method. If it isn't DOJO widget tag, then just return null.
Additionally there are two hook methods for a technical developer to implement more flexible tag handlers.
protected void beforeGenerateTag(StringBuffer buffer)
The method is used for subclass to inject other JavaScript code or generate hidden HTML fields before BTT generate dojo code.
protected void afterGenerateTag(StringBuffer buffer)
The method is used for subclass to inject other JavaScript code or generate hidden HTML fields after BTT generate dojo code.
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 WebSphere Multichannel Bank Transformation Toolkit 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. You can access http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd for more information.



Feedback