DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=15799>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=15799

Nested tags picks up wrong bean for values

           Summary: Nested tags picks up wrong bean for values
           Product: Struts
           Version: 1.0 Beta 3
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: Custom Tags
        AssignedTo: [EMAIL PROTECTED]
        ReportedBy: [EMAIL PROTECTED]


I located the source of the problem, which is caused 
by a change to the nested tags. The code causing the error is this block
found in the NestedPropertyHelper.getNestedNameProperty method.
 
The name property for any tag that extends
org.apache.struts.taglib.html.BaseFieldTag 
is initialized to a constant value of 
Constants.BEAN_KEY. That means the test for 
null is never met so the innermost nested 
tag's (which is the nested:text tag in this case) 
name is used in some cases. 
 
Removing this code should fix my case, but 
I suspect that there was a reason for this 
change, which was made shortly after beta 2 
was released. Here is a patch that is less 
drastic than the removal. This patch makes 
the minimal change, but there are still cases 
in the existing code where errors are not 
dealt with that should probably be fixed.

Index: NestedPropertyHelper.java
===================================================================
RCS file: /home/cvspublic/jakarta-
struts/src/share/org/apache/struts/taglib/nested/NestedPropertyHelper.java,v
retrieving revision 1.11
diff -u -r1.11 NestedPropertyHelper.java
--- NestedPropertyHelper.java   16 Nov 2002 07:07:07 -0000      1.11
+++ NestedPropertyHelper.java   4 Jan 2003 07:14:13 -0000
@@ -65,6 +65,7 @@
 import javax.servlet.jsp.tagext.Tag;
 
 import org.apache.struts.taglib.html.FormTag;
+import org.apache.struts.taglib.html.Constants;
 
 /** A simple helper class that does everything that needs to be done to get 
the
  * nested tag extension to work. Knowing what tags can define the lineage of
@@ -211,11 +212,17 @@
     Tag namedTag = (Tag)tag;
 
     // see if we're already in the right location
+    String defaultName = null;
     if (namedTag instanceof NestedNameSupport) {
            String name = ((NestedNameSupport)namedTag).getName();
-           // return if we already have a name
+           // return if we already have a name and not just default
            if (name != null) {
-             return name;
+            if (name.equals(Constants.BEAN_KEY)) {
+                defaultName = name;
+            }
+            else {
+                return name;
+            }
            }
     }
 
@@ -228,7 +235,11 @@
               !(namedTag instanceof NestedParentSupport) );
     
     if (namedTag == null) {
-      // need to spit some chips
+        // Return default name because parent is not more specific.
+        if (defaultName != null) {
+            return defaultName;
+        }
+        // need to spit some chips
     }
     
     String nameTemp = null;

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

Reply via email to