Attached is a bugfix for 11884: getParent in a SimpleTag implementation
returns a Tag.

TagAdapter now works as per the spec.

Files modified:

    jsr152/src/share/javax/servlet/jsp/tagext/TagAdapter.java

--
Mark Roth, Java Software
Co-Specification Lead for JSP 2.0
Sun Microsystems, Inc.


Index: jsr152/src/share/javax/servlet/jsp/tagext/TagAdapter.java
===================================================================
RCS file: /home/cvspublic/jakarta-servletapi-5/jsr152/src/share/javax/servlet/jsp/tagext/TagAdapter.java,v
retrieving revision 1.2
diff -u -r1.2 TagAdapter.java
--- jsr152/src/share/javax/servlet/jsp/tagext/TagAdapter.java	19 Aug 2002 16:29:51 -0000	1.2
+++ jsr152/src/share/javax/servlet/jsp/tagext/TagAdapter.java	21 Aug 2002 21:46:59 -0000
@@ -77,15 +77,22 @@
 {
     /** The simple tag that's being adapted */
     private SimpleTag simpleTagAdaptee;
+
+    /** The parent, of this tag, converted (if necessary) to be of type Tag */
+    private Tag cachedParent;
     
     /**
-     * Creates a new TagAdapter that wraps the given SimeplTag and 
+     * Creates a new TagAdapter that wraps the given SimpleTag and 
      * returns the parent tag when getParent() is called.
      *
      * @param adaptee The SimpleTag being adapted as a Tag.
      */
     public TagAdapter( SimpleTag adaptee ) {
-        this.simpleTagAdaptee = simpleTagAdaptee;
+        if( adaptee == null ) {
+	    // Cannot wrap a null adaptee.
+	    throw new IllegalArgumentException();
+        }
+        this.simpleTagAdaptee = adaptee;
     }
     
     /**
@@ -122,9 +129,18 @@
      * @return The parent of the tag being adapted.
      */
     public Tag getParent() {
-	// Note the parent tag must be an instance of Tag (either a 
-	// direct instance or a wrapped instance).
-	return (Tag)simpleTagAdaptee.getParent();
+	if( this.cachedParent == null ) {
+	    JspTag parent = simpleTagAdaptee.getParent();
+	    if( parent instanceof Tag ) {
+	        this.cachedParent = (Tag)parent;
+	    }
+	    else {
+                // Must be SimpleTag - no other types defined.
+	        this.cachedParent = new TagAdapter( (SimpleTag)parent );
+	    }
+	}
+
+	return this.cachedParent;
     }
     
     /**

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to