[ Team LiB ] |
Using Dynamic AttributesIn addition to using attributes that are declared beforehand, custom tags can also make use of attributes whose names are unknown before runtime. Although this might seem strange, it makes it possible to build tags that are flexible and easier to reuse. Tags that support this kind of behavior are known as dynamic attributes. They implement the DynamicAttributes interface, which consists of only one method:
setDynamicAttribute is called when a tag that has declared that it accepts dynamic attributes is passed an attribute that has not been declared in the TLD. You state that a tag can accept dynamic attributes by adding the <tag> subelement:
The custom tag is responsible for storing the names and values of any dynamic attributes. Listing 16.11 illustrates one way that a tag could save the name and value of an attribute. Listing 16.11 Partial Source Code for dynamic.java
|
[ Team LiB ] |
No comments:
Post a Comment