Prentice Hall and Sun Microsystems. Personal use only; do not redistribute.
14.3 Assigning Attributes to Tags
319
Figure 14 2 Result of SimplePrimeExample.jsp.
14.3 Assigning Attributes to Tags
Allowing tags like
adds significant flexibility to your tag library. This section explains how to add
attribute support to your tags. 
The Tag Handler Class
Providing support for attributes is straightforward. Use of an attribute called
attribute1
 simply results in a call to a method called 
setAttribute1
 in
your class that extends 
TagSupport
 (or otherwise implements the 
Tag
 inter 
face). The attribute value is supplied to the method as a 
String
. Conse 
quently, adding support for an attribute named 
attribute1
 is merely a
matter of implementing the following method:
public void setAttribute1(String value1) {
doSomethingWith(value1);
}
Note that an attribute of 
attributeName
 (lowercase 
a
) corresponds to a
method called 
setAttributeName
 (uppercase 
A
).
Second edition of this book: www.coreservlets.com; Sequel: www.moreservlets.com.
Servlet and JSP training courses by book's author: courses.coreservlets.com.






footer




 

 

 

 

 Home | About Us | Network | Services | Support | FAQ | Control Panel | Order Online | Sitemap | Contact

jsp web hosting

 

Our partners: PHP: Hypertext Preprocessor Best Web Hosting Java Web Hosting Jsp Web Hosting Cheapest Web Hosting

Visionwebhosting.net Business web hosting division of Web Design Plus. All rights reserved