As far as the tag handler class is concerned, there is
no difference. You still need to provide a setter method for the attribute in the form
Chapter 8 ?– Tag Libraries: Advanced Features 386
of setXxx(String value), where Xxx is the name of the attribute with the first
character capitalized. So, if we have attribute1 as our attribute in the tag, we
would have to provide a setter method in the tag handler class like the following:
public void setAttribute1(String value1) {
doSomethingWith(value1);
}
As before, the most common thing to do with the actual value in the setter
method is to store it in a private instance variable for later use.
Dynamic Attribute Values:
Tag Library Descriptor
As before, each attribute needs to be declared inside the TLD. However, because we
want to allow the JSP author to specify dynamic (or runtime) expressions as values
for the attributes, we must specify rtexprvalue to be true, like in the following:
...
mytag
package.TagHandler
...
...
attribute1
true
Dynamic Attribute Values: JSP File
As before, the JSP page has to declare the tag library using the taglib directive.
This is done in the following form:
<%@ taglib uri="..." prefix="..." %>
The usage of the tag is very much the same, except now you are able to specify JSP
expressions as values for the attributes that are declared in the TLD with rtexprvalue
of true.
Pages:
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433