• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

findAncestorWithClass and getParent

 
Surajsingh Thakur
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....
 
raja ram
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
 
sudheer kiran
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