• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

SimpleTags + ClassicTags + getParent()

 
Ranch Hand
Posts: 290
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Steven Colley
Ranch Hand
Posts: 290
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
anyone please?
 
Ranch Hand
Posts: 951
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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

 
Steven Colley
Ranch Hand
Posts: 290
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 290
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
anyone?
 
please buy my thing and then I'll have more money:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic