Win a copy of The Journey To Enterprise Agility this week in the Agile and Other Processes forum! And see the welcome thread for 20% off.
  • 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:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

findAncestorWithClass and getParent  RSS feed

 
Ranch Hand
Posts: 124
Eclipse IDE MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can anyone kindly explain the significance of these two methods seperately..
Most importantly please explain in which circumstances each of these is and can be best used....
 
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

findAncestorWithClass(Tag,Class) is used to get access to at any level of nesting like.

<t:test>
<t:test1>
<t:test2/>
</t:test1>
</t:test>

in this case in <t:test2> tag handler i can use findAncestorWithClass method to directly gain access to <t:test> by specifying the proper arguments.

In case of getParent() we use to move up the levels one by one <t:test2>,<t:test1>,<t:test> and once reached the top most parent this method will return null saying no more parents to move up. Depending on the need we can write this logic in the corressponding tag handlers.

Thanks
 
Ranch Hand
Posts: 237
Firefox Browser MyEclipse IDE Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I ASK YOU WHO IS YOUR PARENT THEN YOU SAY
MY PARENT IS : getParent();

IF I ASK IS tagone IS YOUR PARENT/GRANDPARENT/. THEN YOU check
tagone is from my family tree : findAncestorWithClass(tagsone,TagOne.class);
 
Surajsingh Thakur
Ranch Hand
Posts: 124
Eclipse IDE MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you very much both of you for this Very Good explaination..
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!