• 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

Stumped !! HFSJ : Page 550 : Q3

 
Ranch Hand
Posts: 245
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I know this question has been put up in errata list as having no correct answers.


As per my understanding , container will pass a TagAdpater object wrapping the <siimple Tag 2> , when calling the setParent() method for <classic tag 3> .

So calling a getParent() in <classic tag 3> with return the reference to TagAdapter and calling getParent() on the Tag Adapter reference should give us a reference to the <classic tag 1>

Please point out where my understaning is wrong .
[ September 25, 2006: Message edited by: Vivek Pandey ]
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

So calling a getParent() in <classic tag 3> with return the reference to TagAdapter and calling getParent() on the Tag Adapter reference should give us a reference to the <classic tag 1>



That's right. And getAdaptee() will return a reference to simple tag 2.
That is an interesting point.
 
Vikrant Pandit
Ranch Hand
Posts: 245
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So does it mean that option C is after all correct !!! ???
 
Vikrant Pandit
Ranch Hand
Posts: 245
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I tried out the following code snippets

The Classic Tag



The Simple Tag



The jsp




The output is


## parent is javax.servlet.jsp.tagext.TagAdapter@1d4eeb5
## parent is edu.scwcd.tags.classic.MyClassicTag1@83e35b
## parent is null <-- From the nested classic tag
## parent is null <-- From the top level classic tag



My conclusion is that option C is correct and errata list is wrongly updated

I hope the authors of HFSJ will have something to say about it !!
 
Vikrant Pandit
Ranch Hand
Posts: 245
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry to bump it up like this ....

But somebody share your thoughts on this .... am I making a glaring ,istake ?

or is the errata list wrongly updated (hard to digest)?
 
Ranch Hand
Posts: 299
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I also agree. Yes as far as I know, invoking getParent() on a classic tag will execute getAdaptee().getParent(). So the simple tag which is adapted to the classic tag will be returned by calling getParent()

Someone clarify me if I'm wrong
 
Live a little! The night is young! And we have umbrellas in our drinks! This umbrella has a tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic