You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by lu...@apache.org on 2002/07/18 23:17:27 UTC

cvs commit: jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler Generator.java Node.java

luehe       2002/07/18 14:17:27

  Modified:    jasper2/src/share/org/apache/jasper/compiler Generator.java
                        Node.java
  Log:
  Fixed Bug# 10670: Problem in JSP compilation
  
  Revision  Changes    Path
  1.42      +13 -54    jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Generator.java
  
  Index: Generator.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Generator.java,v
  retrieving revision 1.41
  retrieving revision 1.42
  diff -u -r1.41 -r1.42
  --- Generator.java	17 Jul 2002 21:13:38 -0000	1.41
  +++ Generator.java	18 Jul 2002 21:17:27 -0000	1.42
  @@ -1959,64 +1959,23 @@
   	}
   
   	/*
  -	 * Declares any NESTED scripting variables of the given custom tag,
  -	 * if the given custom tag is not nested inside itself (i.e, has a
  -	 * nesting level of zero). If the custom tag does have a custom nesting
  -	 * level greater than 0, this method declares a scripting variable
  -	 * derived from the tag's "id" attribute (if present), only if its
  -	 * scope is NESTED and it does not match the "id" attribute of any of
  -	 * the enclosing tags of the same (custom) type.
  -	 *
  -	 * Additionally, a NESTED scripting variable is declared only if it
  -	 * has not already been declared in the same Java
  -	 * scope of the generated code, that is, if this custom tag's parent is
  -	 * different from the parent of the custom tag that may already have
  -	 * declared this variable.
  +	 * Declares any NESTED scripting variables of the given custom tag.
   	 */
   	private void declareNestedScriptingVariables(Node.CustomTag n) {
   
  -	    if (n.getCustomNestingLevel() > 0 && !n.hasUnnestedIdAttribute()) {
  -		return;
  -	    }
  -
   	    TagVariableInfo[] tagVarInfos = n.getTagVariableInfos();
  -	    VariableInfo[] varInfos = n.getVariableInfos();
  -	    if ((varInfos == null) && (tagVarInfos == null)) {
  +	    VariableInfo[] nestedVarInfos = n.getNestedVariableInfos();
  +	    if ((nestedVarInfos == null) && (tagVarInfos == null)) {
   		return;
   	    }
   
  -	    if (varInfos != null) {
  -		if (n.getCustomNestingLevel() == 0) {
  -		    // Declare *any* scripting variables with NESTED scope
  -		    for (int i=0; i<varInfos.length; i++) {
  -			if ((varInfos[i].getScope() == VariableInfo.NESTED)
  -			            && varInfos[i].getDeclare()) {
  -			    String name = varInfos[i].getVarName();
  -			    out.printin(varInfos[i].getClassName());
  -			    out.print(" ");
  -			    out.print(name);
  -			    out.println(" = null;");
  -			}
  -		    }
  -		} else {
  -		    /*
  -		     * Declare only scripting variable (with NESTED scope)
  -		     * derived from unnested "id" attribute
  -		     */
  -		    String idAttr = n.getAttributeValue("id");
  -		    for (int i=0; i<varInfos.length; i++) {
  -			if ((varInfos[i].getScope() == VariableInfo.NESTED)
  -			            && varInfos[i].getDeclare()) {
  -			    String name = varInfos[i].getVarName();
  -			    if (idAttr.equals(name)) {
  -				out.printin(varInfos[i].getClassName());
  -				out.print(" ");
  -				out.print(name);
  -				out.println(" = null;");
  -				break;
  -			    }
  -			}
  -		    }
  +	    if (nestedVarInfos != null) {
  +		for (int i=0; i<nestedVarInfos.length; i++) {
  +		    String name = nestedVarInfos[i].getVarName();
  +		    out.printin(nestedVarInfos[i].getClassName());
  +		    out.print(" ");
  +		    out.print(name);
  +		    out.println(" = null;");
   		}
   	    } else {
   		for (int i=0; i<tagVarInfos.length; i++) {
  
  
  
  1.18      +50 -30    jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Node.java
  
  Index: Node.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Node.java,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- Node.java	17 Jul 2002 20:06:59 -0000	1.17
  +++ Node.java	18 Jul 2002 21:17:27 -0000	1.18
  @@ -791,8 +791,8 @@
   	private TagInfo tagInfo;
   	private Class tagHandlerClass;
   	private VariableInfo[] varInfos;
  +	private VariableInfo[] nestedVarInfos;
   	private int customNestingLevel;
  -	private boolean hasUnnestedIdAttribute;
           private ChildInfo childInfo;
   	private boolean implementsIterationTag;
   	private boolean implementsBodyTag;
  @@ -809,7 +809,6 @@
   	    this.tagInfo = tagInfo;
   	    this.tagHandlerClass = tagHandlerClass;
   	    this.customNestingLevel = computeCustomNestingLevel();
  -	    this.hasUnnestedIdAttribute = determineHasUnnestedIdAttribute();
               this.childInfo = new ChildInfo();
   
   	    this.implementsIterationTag = 
  @@ -862,6 +861,7 @@
   	public void setTagData(TagData tagData) {
   	    this.tagData = tagData;
   	    this.varInfos = tagInfo.getVariableInfo(tagData);
  +	    determineNestedVarInfos();
   	}
   
   	public TagData getTagData() {
  @@ -908,13 +908,8 @@
   	    return varInfos;
   	}
   
  -	/*
  -	 * Returns true if this custom tag has an "id" attribute that does
  -	 * not match the "id" attribute of any of its enclosing parent tags of
  -	 * the same custom tag type, and false otherwise. 
  -	 */
  -	public boolean hasUnnestedIdAttribute() {
  -	    return hasUnnestedIdAttribute;
  +	public VariableInfo[] getNestedVariableInfos() {
  +	    return nestedVarInfos;
   	}
   
   	/*
  @@ -998,35 +993,60 @@
   	}
   
   	/*
  -	 * Checks to see if this custom tag has an "id" attribute that does
  -	 * not match the "id" attribute of any of its enclosing parent tags of
  -	 * the same custom tag type.
  -	 */
  -	private boolean determineHasUnnestedIdAttribute() {
  -	    boolean unnested = false;
  -
  -	    String id = getAttributeValue("id");
  -	    if (id != null) {
  -		if (customNestingLevel == 0) {
  -		    // tag not nested inside itself
  -		    unnested = true;
  -		} else {
  +	 * Determines all the scripting variables with NESTED scope contained
  +	 * in this custom action's VariableInfo[] that are not already
  +	 * contained in the VariableInfo[] of a custom action of the same type
  +	 * in the parent chain.
  +	 */
  +	private void determineNestedVarInfos() {
  +
  +	    if (varInfos == null) {
  +		return;
  +	    }
  +
  +	    Vector vec = new Vector();
  +
  +	    if (customNestingLevel == 0) {
  +		// tag not nested inside itself
  +		for (int i=0; i<varInfos.length; i++) {
  +		    if (varInfos[i].getScope() == VariableInfo.NESTED
  +			    && varInfos[i].getDeclare()) {
  +			vec.add(varInfos[i]);
  +		    }
  +		}
  +	    } else {
  +		for (int i=0; i<varInfos.length; i++) {
  +		    if (varInfos[i].getScope() != VariableInfo.NESTED
  +			    || !varInfos[i].getDeclare()) {
  +			continue;
  +		    }
   		    Node p = parent;
  -		    while (p != null) {
  +		    boolean found = false;
  +		    while ((p != null) && !found) {
   			if ((p instanceof Node.CustomTag)
  -			      && name.equals(((Node.CustomTag) p).name)
  -			      && id.equals(p.getAttributeValue("id"))) {
  -			    break;
  +			        && name.equals(((Node.CustomTag) p).name)) {
  +			    VariableInfo[] parentVarInfos
  +				= ((Node.CustomTag) p).getVariableInfos();
  +			    for (int j=0; j<parentVarInfos.length; j++) {
  +				if (varInfos[i].getVarName().equals(
  +			                    parentVarInfos[j].getVarName())) {
  +				    found = true;
  +				    break;
  +				}
  +			    }
   			}
   			p = p.parent;
   		    }
   		    if (p == null) {
  -			unnested = true;
  +			vec.add(varInfos[i]);
   		    }
  -		}
  +		}		    
   	    }
   
  -	    return unnested;
  +	    if (vec.size() > 0) {
  +		nestedVarInfos =
  +		    (VariableInfo[]) vec.toArray(new VariableInfo[vec.size()]);
  +	    }
   	}
       }
   
  
  
  

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