• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Custom Tag Qn

 
Chandrakanth
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I found this qn in one of the mocks, Ans to this qn is E,
Can some body explain how its E, as i was thinking C will be more appropriate.

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.
 
Rodrigo Alvarez
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Option C says that doAfterBody is only called when doStartTag() returns EVAL_BODY_INCLUDE or EVAL_BODY_BUFFERED, but there are other possibilities (like the one described in option E). => C is not correct

If doAfterBody returns EVAL_BODY_AGAIN, then doAfterBody is called once again => E is correct
[ May 22, 2006: Message edited by: Rodrigo Alvarez ]
 
Reshma Shanbhag
Ranch Hand
Posts: 208
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Analyzing the given options

a.) Wrong, as the doStartTag() will have to return EVAL_BODY_INCLUDE even though the body of the Tag is not empty by default doStartTag() retuns SKIP_BODY.

b.) Wrong, the method will never be invoked if the body is empty.


c.) doStartTag() returns BodyTag.EVAL_BODY_BUFFERED the doAfterBody() is not invoked !!!, the content of the body is buffered.

d.) Wrong. doAfterBody() if invoked is executed after doStartTag() and before doEndTag().

e.)TRUE. the doAfterBody is re executed if doAfterBody() returns EVAL_BODY_AGAIN.


From the above choices E is the most appropriate answer to me.


Hope that helps
Reshma
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic