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!
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 ]
Joined: Oct 28, 2002
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".