File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Simple/Classic tag parent access Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Simple/Classic tag parent access" Watch "Simple/Classic tag parent access" New topic
Author

Simple/Classic tag parent access

Ronan Dowd
Ranch Hand

Joined: Jan 21, 2006
Posts: 84
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


SCJP 1.4 | OCWCD JEE 5
Frits Walraven
Creator of Enthuware JWS+ V6
Bartender

Joined: Apr 07, 2010
Posts: 1632
    
  23

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

Joined: Nov 04, 2009
Posts: 2066

But, TagAdapter class isn't in the exam objective?


|BSc in Electronic Eng| |SCJP 6.0 91%| |SCWCD 5 92%|
Frits Walraven
Creator of Enthuware JWS+ V6
Bartender

Joined: Apr 07, 2010
Posts: 1632
    
  23

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

Joined: Nov 04, 2009
Posts: 2066

Thanks Frits! Me too. And it's good to see you as a Rancher here~!
Frits Walraven
Creator of Enthuware JWS+ V6
Bartender

Joined: Apr 07, 2010
Posts: 1632
    
  23

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

Thanks

Regards,
Frits
 
 
subject: Simple/Classic tag parent access
 
Similar Threads
Custom tags Qn in K &B pg 560
HF chap.10 : don't understand answer for Q3
Doubt on Tag Handlers
Doubt on Q 3 HFSJ chapter 10
SimpleTags + ClassicTags + getParent()