Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Question about custom tag handler and TLD

 
Paul Statham
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Guys,

I'm just working my through the HFSJ in chapter 9 it talks about a custom tag handler to go along with the TLD that is defined, here's a snippet from each





My question is, there is only one attribute associated with this tag, but if there was another attribute called say test, would you have to add another String called test and a method called setTest inside the TagHandler?
 
Mike Zal
Ranch Hand
Posts: 144
Fedora Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you want to add another attribute to the tag you must do the following:
1) Inside the TagHandler: Add the private String variable
2) Inside the TagHandler: Write the setter method for the attribute
3) Update the TLD to have another attribute element
4) Update the JSP code to use the new attribute and test it out
 
Paul Statham
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Mike, pretty much what I thought it would be
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic