• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

A question from mock exam

 
seema khot
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is a question from JWebPlus mock exam.
Which of the following is a correct statement about the life-cycle methods of a custom tag?
1. setBodyContent is always called on a tag handler that implements BodyTag
2. doAfterBody is always called on a tag that implements IterationTag.
3. doAfterBody will be called if the handler extends TagSupport
4. doAfterBody will be called if the handler extends IterationTagSupport
Corret answer given is 3. and explanation to the statement is ---
TagSupport implements IterationTag. Therefore, doAfterBody() will be called if the handler extends TagSupport.
However, it looks like the default return value for the doStartTag() in TagSupport is SKIP_BODY. If doStartTag() returns SKIP_BODY, will the body then not be evaluated and the next method called would be doEndTag()???
It doesn't seem like JUST because we extend TagSupport that doAfterBody() is guaranteed to be called.
Any Ideas ???
 
Paul Anilprem
Enthuware Software Support
Ranch Hand
Posts: 3776
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are right. It should say something like, "doAfterBody may be called if the handler extends TagSupport"
Can you please mention the question id so that I can make a correction?
 
seema khot
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your reply.
Here is the Question ID :1021097621653
 
Mike J. Beaty
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why is number 1 incorrect?
If you were to implement the BodyTag interface when would the servlet container not call this method?
 
Jian Su
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When doStartTag() returns SKIP_BODY, it would not be called.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic