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

BodyTag interface ques.

 
mallika shah
Ranch Hand
Posts: 164
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
a ques:

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?

1.It is an empty tag.
2.It may be used as an empty tag.
3.It must have a body.
4.It must implement BodyTag interface.
5.It may take an attribute named 'name'. But if present, its value must be dynamic.
ans:2,4
My question:Why is it so , that the if the body-content is tagdependant then it must implement the bodytag interface??
please help? i dont understand this point.

thanks,
mallika
 
Rancy Chadha
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Mallika,

Once again I am not sure if my answer is correct or not, but here is what I have to say regarding your question:

My question:Why is it so , that the if the body-content is tagdependant then it must implement the bodytag interface??

It is not always that if body-content is tagdependent then the helper class should implement BodyTag interface. The reason why I think the option 4 that says "It must implement BodyTag interface" should be selected as one of the right options is because of the description of the tag:

<description>
Replaces emoticons such as , , and with images.
</description>

How we can implement the helper class relies on the description that we have in the TLD file. What we have to do here is, depending on the choice of smiley selected by the user we have to replace them with their corresponding image i.e we have to use the body content of the tag to determine which image is to be selected. And we know that it is only BodyTag interface that can help us to access the body content of the tag and use it to select the image.
Another thing here is TLD file has body-content set to 'tagdependent' because what ever user puts in the body of the tag we want to process it as the template text. I dont think body-content set to tagdependent has any relation with compulsary implementation of the BodyTag interface.

I hope this makes sense to you and your doubt is cleared but in case I am not correct on this, please do let me know.

Thanks
-Rancy
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic