Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Stumped !! HFSJ : Page 550 : Q3

 
Vikrant Pandit
Ranch Hand
Posts: 245
  • Mark post as helpful
  • send pies
  • 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 ]
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
  • 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)?
 
Dilshan Edirisuriya
Ranch Hand
Posts: 299
  • Mark post as helpful
  • send pies
  • 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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic