This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of The Little Book of Impediments (e-book only) and have Tom Perry on-line!
See this thread for details.
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

TLD Doubt

 
Brijesh shah
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello;

Would apreciate if somebody help me out on following question..

16.Consider the following description of a tag in a TLD:
<tag>

<name>SmilyTag</name>

<tag-class>com.enthuware.ctags.SmilyTag</tag-class>

<description>

Replaces emoticons such as , , and with images.

</description>

<body-content>tagdependent</body-content>

<attribute>

<name>name</name>

<required>false</required>

<rtexprvalue>true</rtexprvalue>

</attribute>

</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...

Regards;
Brijesh
 
Atul Samnerkar
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ans B: It may be used as an empty tag.

<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.

Hope this clarifies your doubts.

Cheers...
Atul Samnerkar
 
Sarat Koduri
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thats a good one atul.. i am sure you gave a clear info about that option D.
 
raja ram
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

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.

Thanks
 
Sarat Koduri
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
raja ram
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

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.

Thanks
 
tarun modi
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am not convinced by your explanation in :


because in HFSJ Ch.9 they have written "A tag can have a body only if the <body-content> element for this tag is not configured with a value of empty"

Is i am interpreting the statement correctly???
Please explain it further...
[ October 02, 2008: Message edited by: tarun modi ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic