• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

method findAncestorWithClass

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

I am working on JSP 2.0 - creating custom tags.

I have created two tags (lets say outer and inner) one nested within the other tag. The inner tag uses the method findAncestorWithClass inorder to get a reference to the outer tag. I worked out this with classic tag handler (dostarttag and doendtag) and it works fine, but when i work with simpletagsupport overriding the doTag method, the findAncestorWithClass method returns null.

The code in the inner tag handler
=================================
public void doTag() throws JspException, IOException {
JspWriter out = getJspContext().getOut();
HelloSimpleTag hst = (HelloSimpleTag)findAncestorWithClass(this, HelloSimpleTag.class);
if (hst != null) {
int j = hst.sub(5,3);
out.println("<br>This is from the second tag" + j + "<br>");
}
else
out.println("No parent tag");
}
The TLD file
============
// outer tag
<tag>
<name>Display</name>
<tag-class>com.chennaihome.HelloSimpleTag</tag-class>
<body-content>tagdependent</body-content>
</tag>

// inner tag
<tag>
<name>SecTag</name>
<tag-class>com.chennaihome.SecondTag</tag-class>
<body-content>empty</body-content>
</tag>

Can anyone help me with this?

Thanks and Regards
Usha
 
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"Usha K.V",

There aren't many rules that you need to worry about here on the Ranch, but one that we take very seriously regards the use of proper names. Please take a look at the JavaRanch Naming Policy and adjust your display name to match it.

In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.

Thanks!
bear
JavaRanch Sheriff
 
Usha K.V
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

My full name is Usha K.V and people call me as usha always.

Regards
Usha K.V
 
Bear Bibeault
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Initials are not acceptable for last names. Please read my reply and adjust your display name accordingly.
reply
    Bookmark Topic Watch Topic
  • New Topic