Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
</tag> Which of the following statements regarding the above tag are correct?
Select 2 correct options. A.It is an empty tag. B.It may be used as an empty tag. C.It must have a body D.It must implement BodyTag interface. E.It may take an attribute named 'name'. But if present, its value must be dynamic.
In this i choose C and E But answer given is B and D If answer is B so please explain me as bodycontent is given as tagdependent then how its body may be keep empty... As answer E How can we say it will implemnt bodyTag interface only...
<body-content>tagdependent</body-content> --> This means, if the body exists then it should follow tagdependent rules. It doesn�t force that body has to be present. As there is no compulsion on the body, this tag MAY be used as empty tag.
Ans D: It must implement BodyTag interface
A tag that processes its body contents should implement either BodyTag interface or extends BodyTagSupport. In the given case, tag is meant for "Replaces emoticons such as ... with images". This clearly indicates that tag should process the body contents. Hence Tag must implement BodyTag interface.
I have a doubt on this option D because even if i have a taghandler that extends SimpleTag class i can still process the body of the tag for that matter even for TagSupport class we can process the body of the tag not only for the BodyTagSupport I am confused how can option D be the answer for this can any body please explain this in more details.
raja .. i am not sure about the SimpleTag thing but i can tell you about the TagSupportthing..
The TagSupport only allows us to do either include the body again or to go ahead with out doing again.. thats it .. but it will not allow us to manipulate the body content at any point of time, whereas the BodyTag will allow us to work with the body of the Tag.
Hope you got it.. [ September 30, 2008: Message edited by: Sarat Koduri ]
In case of SimpleTag we can call getJspBody().invoke(null) this will actually process the tag body puts it in the servletoutput stream but we cant modify the Actual body contents even though we can process it using the above tag.
when it comes to,TagSupport and BodyTagSupport using EVAL_BODY_INCLUDE we can process the tags body but we cant modify it similar to the SimpleTag but when we have BodyTagSupport we have EVAL_BODY_BUFFERED and initBody() and setBodyContent() methods with the help of this we can actually modify the tags body contents.
In the question they have asked to modify the tags body contents, so the answer will be BodyTagSupport is my understanding Correct.