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

classic tag access a simple parent?

 
John Wallace
Greenhorn
Posts: 17
Java jQuery PHP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Using the getParent() method, is it possible for a Classic Tag to access a Simple Tag parent?

For example:

================

Consider a JSP page that contains the following code:

10. <x:outer>
11. <x:middle>
12. <x.inner></x.inner>
13. </x:middle>
14. </x:outer>


Assuming the following implementation details...

1. x:outer is implemented by OuterTag.java, which extends SimpleTagSupport.
2. x:middle is implemented by MiddleTag.java, which extends BodyTagSupport and has a body-content of tagdependent.
3. x:inner is implemented by InnerTag.java, which extends BodyTagSupport and has a body-content of tagdependent.

================

Can MiddleTag can get a reference to OuterTag by calling TagSupport.getParent() method?


 
Vishwanath Krishnamurthi
Ranch Hand
Posts: 331
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No. TagSupport.getParent() implements Tag.getParent() which has Tag as the return type. Since a Simple Tag cannot be cast into a Tag, in this case, MiddleTag cannot get a reference to OuterTag by calling TagSupport.getParent() method.

HTH,
Vishwa
 
Mateus Lucio
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, it is possible to get a SimpleTag Parent calling getParent() method in a ClassicTag, since SimpleTags have another class hierarchy you cannot directly cast you SimpleTag parent reference, for that a TagAdapter is supplied, take a look at javax.servlet.jsp.tagext.TagAdapter, it's mainly purpose is to wrap a SimpleTag and exposes it as a Tag reference.
 
namita sasa
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The body-content is defined as non-tagdependent that means we can have scriplets, EL and tags allowed. I am confused!
Please help. Sorry for posting this in incorrect topic.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic