Class 2 |
Intermediate Java 30-IT-397 |
|
What we need to change...
-
First, we need to make a Tag Handler class, RowBody, and add the doEndTag()
method to it.
-
I just copy-pasted the Row class and added doEndTag.
-
Now, the JSP:
-
Replace the </td> with </tbl:RowBody>.
-
Take the last '/' out of <tbl:RowBody color="#00673E" />. This
is important, the compiler treats that last '/' as the end of the tag.
If you do not do this, you will get goofy results!
-
And, the TLD:
-
I kept the same .tld and web.xml entry for ease.
-
You need to add this to the TLD:
<tag>
<name>RowBody</name>
<tag-class>table.RowBody</tag-class>
<body-content>JSP</body-content>
<description> Generate Complete Table Row
</description>
<attribute>
<name>color</name>
<required>false</required>
</attribute>
</tag>
-
An interesting note, though. The book uses <bodycontent> as one
word. This will not work in Tomcat. You must use the
dash to separate body and content.
ColorBarBody source
(The results are identical to the ColorBar we saw before.)
RowBody.java source
Altering the Tag Body

Created by: Brandan Jones
December 17, 2001