File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Simple/Classic tag parent access

 
Ronan Dowd
Ranch Hand
Posts: 84
  • 0
  • Mark post as helpful
  • send pies
  • 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
 
Frits Walraven
Creator of Enthuware JWS+ V6
Saloon Keeper
Pie
Posts: 2166
57
Android Chrome Eclipse IDE
  • 0
  • Mark post as helpful
  • send pies
  • 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
 
Abimaran Kugathasan
Ranch Hand
Posts: 2066
Clojure IntelliJ IDE Linux
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But, TagAdapter class isn't in the exam objective?
 
Frits Walraven
Creator of Enthuware JWS+ V6
Saloon Keeper
Pie
Posts: 2166
57
Android Chrome Eclipse IDE
  • 0
  • Mark post as helpful
  • send pies
  • 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
Clojure IntelliJ IDE Linux
  • 0
  • Mark post as helpful
  • send pies
  • 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
Saloon Keeper
Pie
Posts: 2166
57
Android Chrome Eclipse IDE
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And it's good to see you as a Rancher here~!

Thanks

Regards,
Frits
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic