• 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
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

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..
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!