• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

parent and child: simple tag and classic tag

 
warren li
Ranch Hand
Posts: 128
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HFSJ book says, simple tag can have simple tag or classic tag as the parent.
classic tag can have classic tag as the parent.

it also says classic tag can have simple tag as parent by some "hacks".

What I am curious is, what is on the exam topic? If a classic tag is enclosed by a simple tag in a question, is it considered legal?

Thanks for clarification.
 
Sergio Tridente
Ranch Hand
Posts: 329
Java Linux Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am also stdudying for the SCWCD exam and I have just passed through the tag's chapter. So, please, if I am making a mistake somebody correct me.

I will try to answer your question. I had the same doubts that you are having now and I simply coded two tags, one extending SimpleTagSupport and another extending TagSupport. Then in my JSP I tried dufferent combinations: Simple tag parent and "Classic" tag child, "Classic" tag parent and Simple tag child, etc. I also tried nesting the tags in several levels. The results were that I was able to have any combination that I wanted... with a couple of caveats:
1) Rememember you cannot have scripting inside a tag handler implementing the SimpleTag interface (that includes any scripting element that may be inside a "Classic" tag which is nested inside a SimpleTag, even if it is several levels under). Remember: scripting inside Simple tags is a no-no.
2) You need to be careful when calling getParent(), specially if you are iterating throughout the whole "parent-chain". The problem can be solved by using TagAdapter class (or by playing with introspection a little). If I undertand it correctly the TagAdapter class is what setParent() using to circunvent problems between Simple and "Classic" tags parent0child combinations. I do not know if you will be tested on that for the exam (I thik you won't), but I like to understand how things work (I have an awful memory, and this is the only way I can learn something :-).

I hope I am accurate and this helps you in some way.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic