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 2003/01/11 01:52:14 UTC

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

luehe       2003/01/10 16:52:14

  Modified:    jasper2/src/share/org/apache/jasper/compiler Generator.java
                        Node.java
  Log:
  Fixed 15961: getBodyContent() is not returning null when the action
  has only jsp:attribute actions within the body.
  
  Revision  Changes    Path
  1.147     +6 -6      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.146
  retrieving revision 1.147
  diff -u -r1.146 -r1.147
  --- Generator.java	8 Jan 2003 22:15:56 -0000	1.146
  +++ Generator.java	11 Jan 2003 00:52:14 -0000	1.147
  @@ -1958,7 +1958,7 @@
   		syncScriptingVars(n, VariableInfo.AT_BEGIN);
   	    }
   
  -	    if (n.getBody() != null) {
  +	    if (!n.hasEmptyBody()) {
   		out.printin("if (");
   		out.print(tagEvalVar);
   		out.println(" != javax.servlet.jsp.tagext.Tag.SKIP_BODY) {");
  @@ -2003,7 +2003,7 @@
   				       String tagHandlerVar,
   				       String tagEvalVar) {
   
  -	    if (n.getBody() != null) {
  +	    if (!n.hasEmptyBody()) {
   		if (n.implementsIterationTag()) {
   		    out.printin("int evalDoAfterBody = ");
   		    out.print(tagHandlerVar);
  @@ -2120,7 +2120,7 @@
   		 * and pass it to tag handler's setJspBody(), unless tag body
   		 * is empty
   		 */
  -		if (n.getBody() != null) {
  +		if (!n.hasEmptyBody()) {
   		    out.printin(tagHandlerVar);
   		    out.print(".setJspBody(");
   		    generateJspFragment(n, tagHandlerVar);
  
  
  
  1.53      +34 -3     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.52
  retrieving revision 1.53
  diff -u -r1.52 -r1.53
  --- Node.java	11 Jan 2003 00:11:06 -0000	1.52
  +++ Node.java	11 Jan 2003 00:52:14 -0000	1.53
  @@ -1265,6 +1265,37 @@
   	    }
   	    return n;
   	}
  +
  +	/**
  +	 * Returns true if this custom action has an empty body, and false
  +	 * otherwise.
  +	 *
  +	 * A custom action is considered to have an empty body if the 
  +	 * following holds true:
  +	 * - getBody() returns null, or
  +	 * - all immediate children are jsp:attribute actions, or
  +	 * - the action's jsp:body is empty.
  +	 */
  +	 public boolean hasEmptyBody() {
  +	     boolean hasEmptyBody = true;
  +	     Nodes nodes = getBody();
  +	     if (nodes != null) {
  +		 int numChildNodes = nodes.size();
  +		 for (int i=0; i<numChildNodes; i++) {
  +		     Node n = nodes.getNode(i);
  +		     if (!(n instanceof NamedAttribute)) {
  +			 if (n instanceof JspBody) {
  +			     hasEmptyBody = (n.getBody() == null);
  +			 } else {
  +			     hasEmptyBody = false;
  +			 }
  +			 break;
  +		     }
  +		 }
  +	     }
  +
  +	     return hasEmptyBody;
  +	 }
       }
   
       /**
  
  
  

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