If you use an include directive, like: <%@ include file="pageContainingTag2.jsp" %>
instead of a JSP include, then findAncestorWithClass() will work. --Dan Martin Cooper wrote: >One thing to be aware of with findAncestorWithClass() is that it works only >within the JSP page. This is not surprising in itself. However, if you want >to be able to have the nested tag in an included page, you can't use this >mechanism to find the parent. > >That is, with this code in the page: > > <mytags:tag1 ... > > <mytags:tag2 ... /> > </mytags:tag1> > >tag2 can find tag1 using findAncestorWithClass() just fine. However, with >this: > > <mytags:tag1 ... > > <jsp:include page="pageContainingTag2.jsp" /> > </mytags:tag1> > >tag2 will be unable to find tag1 using findAncestorWithClass(). > >It may not always be necessary to be able to do this, but I point it out >because we had this issue with the Struts HTML tags. The various <html:*> >tags need to refer to their containing <html:form> tag. However, if the form >gets very large, and the page breaks the limit on the size of a compiled >method, you are forced to split the form across pages. To make this work in >Struts, the doStartTag() method in <html:form> stores a reference to itself >as a request attribute, the nested tags use that, and then doEndTag() cleans >it up. > >-- >Martin Cooper > > >----- Original Message ----- >From: Shawn Bayern <[EMAIL PROTECTED]> >To: Tag Libraries Users List <[EMAIL PROTECTED]>; ><[EMAIL PROTECTED]> >Sent: Wednesday, December 05, 2001 12:20 PM >Subject: Re: How to determing the relationship between tags > > >>On Wed, 5 Dec 2001, bo wrote: >> >>>I wonder if I can determine the relationship among tags, such as tag A >>>should be within tag B etc. Is that possible? Thanks! >>> >>You can use a TagLibraryValidator class to enforce arbitrary >>characteristics of the XML view of a JSP page, including specific >>relationships among tags. For an example of a SAX-based approach to >>validation, see the JstlCoreTLV class in the "Standard" taglib. >> >>Tags can also, at runtime, gain access to their parent tag handlers. The >>most convenient mechanism for doing this is, in most cases, the static >>TagSupport.findAncestorWithClass() method, part of the JSP API. >> >>Hope that helps, >> >>Shawn >> >> >>-- >>To unsubscribe, e-mail: >> ><mailto:[EMAIL PROTECTED]> > >>For additional commands, e-mail: >> ><mailto:[EMAIL PROTECTED]> > > > >-- >To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> >For additional commands, e-mail: <mailto:[EMAIL PROTECTED]> > -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>