aspose file tools*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes SimpleTags + ClassicTags + getParent() 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 "SimpleTags + ClassicTags + getParent()" Watch "SimpleTags + ClassicTags + getParent()" New topic
Author

SimpleTags + ClassicTags + getParent()

Steven Colley
Ranch Hand

Joined: Feb 18, 2005
Posts: 290
Hi i have a question regarding "getParent()" method from SimpleTag and Tag interfaces.

(HFJ&S page 550, question 3 - option C).

"Tag3Handler MAY use the getParent method twice to gain access to the instance of Tag1Handler" wish is a ClassTag as well. (book says : FALSE - errata)


My questiob is:

According to my tests, we could even get access to "<my:tag2>" wich is a SimpleTag using "getParent()".

In fact, what we COULDN`T do is to get access to "its methods" (ClassCastException).

The point is.."classic tags (inner - <my:tag3> can access simpletags(outer - <my:tag2> ..and therefore to get access to the classictag (outer - <my:tag1> .


was i clear?
Does it make sense??


Tks in advance.

Tks.


SCJP | SCWCD | SCBCD | SCWSD 5 | SCEA (I) 1.4 | SCEA 5 | IBM SOA 669
Steven Colley
Ranch Hand

Joined: Feb 18, 2005
Posts: 290
anyone please?
Narendra Dhande
Ranch Hand

Joined: Dec 04, 2004
Posts: 950
Hi,

The point is.."classic tags (inner - <my:tag3> can access simpletags(outer - <my:tag2> ..and therefore to get access to the classictag (outer - <my:tag1> .




<tag1 .. > -- Classic tag
<tag2 .. > -- Simple tag
<tag3 ..> -- classic tag
</tag3>
</tag2>
</tag1>
/QUOTE]

This is valid. You can nest simple and custom tags. Here the tag3 use the TagAgaptor to wrap the tag2 tag. TagAdaptor class wrap the SimpleTag and expose it as a Tag interface. The TagAdaptor take SimpleTag as argument to constructor and give all methods as the Tag interface. Only the getParent and the getAdoptee methods are implemented all the other Tag methods return UnSupportedException.

Hope this help

Thanks


Narendra Dhande
SCJP 1.4,SCWCD 1.4, SCBCD 5.0, SCDJWS 5.0, SCEA 5.0
Steven Colley
Ranch Hand

Joined: Feb 18, 2005
Posts: 290
Right Narendra,

But when "tag3" tries to get access to the "tag2�s methods", it returns "ClassCastException", ins�t it?

And another thing...so it��s **CORRECT** to say that ClassicTags "can" also get access to SimpleTags "DIRECTLY"?

or is it **WRONG**? BECAUSE it needs to utilize a TagAdpter "INDIRECTLY" for this?


Please folks, help us. It�s important for the exam.

Tks a lot.

cya.
Steven Colley
Ranch Hand

Joined: Feb 18, 2005
Posts: 290
anyone?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: SimpleTags + ClassicTags + getParent()