Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

classic Tag

 
priya Agrawal
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tags questions are:

1)What is difference between tag implement by classic tag and Simple Tag
2)Can I nested a classic tag action in the simple tag action please explain
3)Can I nested a simple tag action in the classic tag action please explain
4)Can Classic and simple tag both include jsp in the body.


Thanks
 
Shivani Chandna
Ranch Hand
Posts: 380
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
custom tag can be implemented by simple and classic tag handlers.
The simple tag has as its name suggests - simplified API. Especially for body-content execution and evaluation(uses JspFragment).

Looking at the tld one cannot distinguish if the tag is simple or classic.


Classic tag can alone(and not simple tag)can have JSP as body-content.
Simple tags need to have scriptless body.

Simple and Classic tags can be nested in each other.
Only the issue is if you nest classic tag inside simple tag -

<my:simpleTag>
<my:classicTag/>
<my:simpleTag>

One needs to use the class TagAdapter for getting parent. Since simple tag is of type JspTag and Classic tag is of type Tag. (Remember Tag is subclass of JspTag).From the API:


Because SimpleTag does not extend Tag, and because Tag.setParent() only accepts a Tag instance, a classic tag handler (one that implements Tag) cannot have a SimpleTag as its parent. To remedy this, a TagAdapter is created to wrap the SimpleTag parent, and the adapter is passed to setParent() instead. A classic Tag Handler can call getAdaptee() to retrieve the encapsulated SimpleTag instance.


TagAdapter(SimpleTag adaptee) - constructor
JspTag getAdaptee() - returns the JspTag reference to Classic tag.
[[ Gets the tag that is being adapted to the Tag interface.]]


Regards,
Shivani
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic