• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

method findAncestorWithClass

 
Usha K.V
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • 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
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64721
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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
  • 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
Author and ninkuma
Marshal
Pie
Posts: 64721
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Initials are not acceptable for last names. Please read my reply and adjust your display name accordingly.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic