[ http://issues.apache.org/struts/browse/STR-1084?page=all ]
     
David Evans resolved STR-1084:
------------------------------

    Resolution: Fixed

> Nested tags picks up wrong bean for values
> ------------------------------------------
>
>          Key: STR-1084
>          URL: http://issues.apache.org/struts/browse/STR-1084
>      Project: Struts Action 1
>         Type: Bug

>   Components: Taglibs
>     Versions: 1.1 Beta 3
>  Environment: Operating System: All
> Platform: All
>     Reporter: David Morris
>      Fix For: 1.1 Family

>
> 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;

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/struts/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


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

Reply via email to