You are right! the code will be inside the classic tag handler class
If you extends TagSupport, it's no need to implements the .getParent() method , TagSupport has done that for you.
It is the responsiblility of container to call the setParent() method of Tag, When the container decide that the parent tag is an instance of SimpleTag it will create a TagAdapter and makes the parent tag(SimpleTag) the adaptee, then pass the adapter (which is an instance of Tag now) as parameter to
setParent() methed of the child Tag (suppose child tag is a classic tag).
so, TagSupport class insure that TagAdpater object is returned if the parent tag is a SimpleTag.
Originally posted by Mukhtar Ahmed:
Hi Mike, Thanks for the reply.
Let me just make sure I understand it right. The following code:
TagAdapter tagAdapter=(TagAdapter)childTag.getParent();
SimpleTag simpleTag = (SimpleTag)tagAdapter.getAdaptee();
will be inside the classic tag handler class (the innerClassic:y).
So who will create the TagAdapter? The container? or do we have to implement childTag.getParent(); method so that it returns TagAdapter?
TagSupport.getParent() returns a Tag. So does the implementation of TagSupport class makes sure that TagAdpater object is returned if the parent tag is a SimpleTag?
Also, while writing a JSP page, do we have to change anything is the parent tag of a classic tag is a SimpleTag? Or the code that I wrote above willl work without any modification? I.e will the following code work?
<outerSimple:x>
<innerClassic:y/>
</outerSimple:x>