aspose file tools*
The moose likes JSP and the fly likes method findAncestorWithClass Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "method findAncestorWithClass " Watch "method findAncestorWithClass " New topic
Author

method findAncestorWithClass

Usha K.V
Greenhorn

Joined: Mar 22, 2006
Posts: 2
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

Joined: Jan 10, 2002
Posts: 61424
    
  67

"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


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Usha K.V
Greenhorn

Joined: Mar 22, 2006
Posts: 2
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

Joined: Jan 10, 2002
Posts: 61424
    
  67

Initials are not acceptable for last names. Please read my reply and adjust your display name accordingly.
 
Consider Paul's rocket mass heater.
 
subject: method findAncestorWithClass