You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by David Morris <Da...@plumcreek.com> on 2003/01/04 08:26:08 UTC

Re: [PATCH] Beta 1.3 pulls tag values from wrong bean

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.

The bugzilla page says to send a patch rather 
to the developer list so here is one.

David Morris

Re: [PATCH] Beta 1.3 pulls tag values from wrong bean

Posted by Ted Husted <hu...@apache.org>.
The general Bugzilla page is wrong in our case (been meaning to fix 
that). We prefer that patches be attached to Bugzilla issues so that 
they dont' get buried on the list =:0)

-Ted.

David Morris wrote:
> 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.
> 
> The bugzilla page says to send a patch rather 
> to the developer list so here is one.
> 
> David Morris
> 
> 
> ------------------------------------------------------------------------
> 
> 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:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>


-- 
Ted Husted,
Struts in Action <http://husted.com/struts/book.html>



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>