Win a copy of 97 Things Every Java Programmer Should Know this week in the Java in General forum!
  • 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
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

findAncestorWithClass and getParent

 
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
MyEclipse IDE Firefox Browser 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..
 
If you send is by car it's a shipment, but if by ship it's cargo. This tiny ad told me:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic