I’m getting sick of these tag attributes!

image with no caption
image with no caption

You’re right. This solution sucks. And it’s tons of code to keep up with. Worse, what if we want to create a suite of custom tags to augment other HTML tags?!

The tag handler class must implement a setter method for each of the tag attributes declared in the TLD. But these setter methods aren’t really doing anything interesting. The values of these attributes are simply passed on to the output generated for the HTML <select> tag.

We could apply an design principle: “Encapsulate that which varies.”[9] In this case the set of optional HTML tag attributes is the thing that varies in this tag handler. One solution would be to put all of the attributes into a hashtable. This generalizes the tag object’s storage of attributes, but what about all these setter methods? We can’t get rid of them unless there’s a way to tell the JSP engine to set the tag attributes using a generic interface.

image with no caption
image with no caption

Relax

You will not be tested on the method signature and definitely not on the purpose of the uri parameter.

Hell, we don’t even know what it’s for.



[9] This design principle is discussed on Head First Object-Oriented Analysis and Design in Can I use cookies for other things, or are they only for sessions?.

Of course, we would never shamelessly plug another Head First book, right?

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset