• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Simple/Classic tag parent access

 
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
According to JSP spec and HFS book, Simple Tags can access either Simple or Classic parent tags but Classic tags can access only Classic Parent tags.
Well consider the below example:

tag1 is a classic tag (extends TagSupport)
tag2 is a simple tag (extends SimpleTagSupport)
tag3 is a classic tag (extends TagSupport)

<my:tag1>
<my:tag2>
<my:tag3/>
</my:tag2>
</my:tag1>

The HFS book (2nd edition, page 560) says that the tag3 handler can call the getParent method twice in order to access the instance of tag1 handler.

I thought that classic tags can only access classic tag parents so how could this work as tag3's parent is a simple tag?

Any advise would be great

Thanks. Ro
 
Creator of Enthuware JWS+ V6
Posts: 3411
320
Android Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Ronan,

I thought that classic tags can only access classic tag parents so how could this work as tag3's parent is a simple tag?


That is done with the TagAdapter class.

Have look at my notes (ScwcdLinks), chapter 9.7

Regards,
Frits
 
Ranch Hand
Posts: 2066
IntelliJ IDE Clojure Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
But, TagAdapter class isn't in the exam objective?
 
Frits Walraven
Creator of Enthuware JWS+ V6
Posts: 3411
320
Android Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The exam objective related to this topic is the following:

Section 10: Building a Custom Tag Library
Given a scenario, write tag handler code to access the parent tag and an arbitrary tag ancestor.


It doesn't explicitly say that the TagAdapter is part of the exam, but it is good to know how it works. You will probably never write your own TagAdapter class unless your are involved in servlet-container development (the container will create the class when it sees that the parent of a Classic Tag is a SimpleTag)

For your information, I didn't get any questions about this on the exam though.

Regards,
Frits
 
Abimaran Kugathasan
Ranch Hand
Posts: 2066
IntelliJ IDE Clojure Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Frits! Me too. And it's good to see you as a Rancher here~!
 
Frits Walraven
Creator of Enthuware JWS+ V6
Posts: 3411
320
Android Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

And it's good to see you as a Rancher here~!


Thanks

Regards,
Frits
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic