Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Tag Handler's Lifecycle - Nested Tags of the same class

 
Ross Sargant
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
There is something I just can't seem to understand regarding a tag handlers lifecyle.
If you have a situation where you have
a nested tag of the same type (ie: same tag handler class) how many instances of that class are in existence, and is there even some kind of guarentee?
Lets say you are doing nested iteration, so you have two nested iteration tags. Furthermore, lets say that for some reason, your iteration tag needs to refer to its enclosing tag.
Is it ever the case that findAncestorWithClass(..)
will return *this*? Is there always two instances of tag handler around in this nested situation or might there only be one?
I just can't seem get a solid understanding of whats going on there. I understand in general, that a tag handler can be reused but will it ever be reused to handle the nesting of itself?
Maybe there is some obvious reason why this isn't possible.. any clarification of what goes on here would be appreciated!
 
Simon Brown
sharp shooter, and author
Ranch Hand
Posts: 1913
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In this situation, there must be two tag handler instances. Since the getParent() method returns the closest enclosing parent, having the same return value for both tags wouldn't make sense. Also, setting values for the tag attributes would overwrite those of the enclosing (parent) tag if the same instance was (re)used.
Hope that helps...
Simon
p.s. I dedicated a section to this in chapter 9 of my book if you have access to a copy
[ October 28, 2002: Message edited by: Simon Brown ]
 
Ross Sargant
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you!
I have been looking for a good answer to this everywhere but nobody ever seemed to understand what I was asking.
Perhaps I will need to get a copy of your book.
So, the bottom line is that for nested tags of the same tag handler class, there will always be as many instances as the depth of the nesting tree, and each has its own state and getParent.. findAcestor never return "this".
 
Simon Brown
sharp shooter, and author
Ranch Hand
Posts: 1913
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes (well, atleast I hope so!).
Simon
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic