• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Section 12.8 of Objectives - Nested TagHandlers?

 
Madhav Lakkapragada
Ranch Hand
Posts: 5040
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
12.8 Identify methods that return an outer Tag Handler from within an inner tag handler.
Ans: (from Michell's notes)
Tag.getParent( ).
TagSupport.getParent( ) (same as above)
TagSupport.findAncestorWithClass(someClass)
Can someone give me a practical scenario where I would use these methods ?
Thanks.
- satya
ps:
Source code would be great, but I don't want to get too greedy. Thoughts, ideas are equally appreciated.
 
Stefan Zoerner
Author
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!
"Core Servlets and JavaServer Pages" by Marty Hall contains a nice example (Chapter 14, Creating Custom JSP TagLibs).
It describes a set of tags that would be used like that:

The implmentation of the condition-, the then- and the else-tag use findAncesteorWithClass to navigate to the surrounding if-tag. The condition-tag sets a boolean-value on that if-tag, the other two are evaluated or not, depending on that value.
You can download the sourcecode of the example at
Book's Website
I hope that is what you are looking for.
Greetings from Hamburg,
Stefan
[ January 18, 2002: Message edited by: Stefan Zoerner ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic