• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

classic tag access a simple parent?

 
Greenhorn
Posts: 17
jQuery PHP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?


 
Ranch Hand
Posts: 331
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
I'm full of tinier men! And a tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic