Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Doubt in doAfterBody

 
geeta vemula
Ranch Hand
Posts: 208
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Question 37 of 60 from enthuware
In which of the following cases will the method doAfterBody() of a tag handler be invoked?



Select 1 correct option.
a This method will always be called when the body of the tag is not empty.
b This method will be called only when the body of the tag IS empty.
c This method will be called only when doStartTag() returns Tag.EVAL_BODY_INCLUDE or BodyTag.EVAL_BODY_BUFFERED.
d This method will be called only when doEndTag() returns Tag.EVAL_BODY_INCLUDE or BodyTag.EVAL_BODY_BUFFERED.
e This method will be called if doAfterBody() returns IterationTag.EVAL_BODY_AGAIN.

Answer is e,
But why not c? because doAfterBody will only called depend on the return values of doStartTag()

Thanks,
Geeta
 
Chinmaya Chowdary
Ranch Hand
Posts: 434
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Geeta. When doStartTag() returns Tag.EVAL_BODY_INCLUDE or BodyTag.EVAL_BODY_BUFFERED, it is not guaranteed to call doAfterBody().

The doAfterBody() will not be called if tag invokes as
1)<tag:MyTag/>
or
2) <tag:MyTag></tag:MyTag>
or
3)<body-content>empty</body-content> in tld file.

Here the option e is more appropriate answer. Sorry for duplicate post.
 
geeta vemula
Ranch Hand
Posts: 208
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But Chinmaya,
Eval_Body_Again is called by doAfterBody() itself.

Then when doAfterbody() method is called for first time?
 
Chinmaya Chowdary
Ranch Hand
Posts: 434
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Geeta. If the tag invokes through body, and the <body-content> declared non empty, then the body is evaluated by the container. After this step, doAfterBody() will be called for the first time.
 
geeta vemula
Ranch Hand
Posts: 208
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
but in lifecycle it is clearly mentioned that if the tag is not declared empty body, and the tag is not invoked with an empty body, and the doStartTag() method return Eval_Body_Include, then the body is evaluated and after that doAfterBody() is called.

What if DoStartTag returns Skip_Body even if both above conditions are true? and the page 536 HFSJ says that The Classic lifecycle depends on return values??
 
Chinmaya Chowdary
Ranch Hand
Posts: 434
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If the doStartTag() returns SKIP_BODY, then doEndTag() will be called.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic