my dog learned polymorphism*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes findAncestorWithClass Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "findAncestorWithClass" Watch "findAncestorWithClass" New topic
Author

findAncestorWithClass

shanthisri mocherla
Ranch Hand

Joined: Sep 05, 2005
Posts: 119
Hello ranchers

I'm having some trouble with the findAncestorWithClass(tag,class) method.

I've a question??
It returns an instance of the class we are passing as the argument to the method right??


So if I have two tags one nested inside the other i.e one parent tag and one child tag.

Then can i get the name of the parent tag by using this method??

<mine:Menu>
<mine:MenuItem/>
</mine:MenuItem>


Thanks for helping me
Shanthi
Vishnu Prakash
Ranch Hand

Joined: Nov 15, 2004
Posts: 1026

I've a question??
It returns an instance of the class we are passing as the argument to the method right??


Correct


So if I have two tags one nested inside the other i.e one parent tag and one child tag.
Then can i get the name of the parent tag by using this method??


Yes you can.

NOTE:
findAncestorWithClass(tag,class) is generally used to get the top-level instance skiping some levels. So if you looking for a immediate parent you can use getParent() method.


Servlet Spec 2.4/ Jsp Spec 2.0/ JSTL Spec 1.1 - JSTL Tag Documentation
 
Don't get me started about those stupid light bulbs.
 
subject: findAncestorWithClass