tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r905560 - in /tomcat/tc6.0.x/trunk/java/org/apache/jasper/compiler: Generator.java ScriptingVariabler.java
Date Tue, 02 Feb 2010 10:01:32 GMT
Author: markt
Date: Tue Feb  2 10:01:29 2010
New Revision: 905560

URL: http://svn.apache.org/viewvc?rev=905560&view=rev
Log:
TCSRV-1180. Fix regression in 6.0.24
https://issues.apache.org/bugzilla/show_bug.cgi?id=48616
Definition of scripting variables

Modified:
    tomcat/tc6.0.x/trunk/java/org/apache/jasper/compiler/Generator.java
    tomcat/tc6.0.x/trunk/java/org/apache/jasper/compiler/ScriptingVariabler.java

Modified: tomcat/tc6.0.x/trunk/java/org/apache/jasper/compiler/Generator.java
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/jasper/compiler/Generator.java?rev=905560&r1=905559&r2=905560&view=diff
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/jasper/compiler/Generator.java (original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/jasper/compiler/Generator.java Tue Feb  2 10:01:29
2010
@@ -167,6 +167,26 @@
         return b.toString();
     }
 
+    /**
+     * Finds the <jsp:body> subelement of the given parent node. If not
+     * found, null is returned.
+     */
+    protected static Node.JspBody findJspBody(Node parent) {
+        Node.JspBody result = null;
+
+        Node.Nodes subelements = parent.getBody();
+        for (int i = 0; (subelements != null) && (i < subelements.size()); i++)
{
+            Node n = subelements.getNode(i);
+            if (n instanceof Node.JspBody) {
+                result = (Node.JspBody) n;
+                break;
+            }
+        }
+
+        return result;
+    }
+
+
     private String createJspId() throws JasperException {
         if (this.jspIdPrefix == null) {
             StringBuffer sb = new StringBuffer(32);
@@ -978,25 +998,6 @@
             }
         }
 
-        /**
-         * Finds the <jsp:body> subelement of the given parent node. If not
-         * found, null is returned.
-         */
-        private Node.JspBody findJspBody(Node parent) throws JasperException {
-            Node.JspBody result = null;
-
-            Node.Nodes subelements = parent.getBody();
-            for (int i = 0; (subelements != null) && (i < subelements.size());
i++) {
-                Node n = subelements.getNode(i);
-                if (n instanceof Node.JspBody) {
-                    result = (Node.JspBody) n;
-                    break;
-                }
-            }
-
-            return result;
-        }
-
         public void visit(Node.ForwardAction n) throws JasperException {
             Node.JspAttribute page = n.getPage();
 

Modified: tomcat/tc6.0.x/trunk/java/org/apache/jasper/compiler/ScriptingVariabler.java
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/jasper/compiler/ScriptingVariabler.java?rev=905560&r1=905559&r2=905560&view=diff
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/jasper/compiler/ScriptingVariabler.java (original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/jasper/compiler/ScriptingVariabler.java Tue Feb 
2 10:01:29 2010
@@ -68,7 +68,7 @@
         public void visit(Node.CustomTag n) throws JasperException {
             setScriptingVars(n, VariableInfo.AT_BEGIN);
             setScriptingVars(n, VariableInfo.NESTED);
-            new ScriptingVariableVisitor(err).visitBody(n);
+            visitBody(n);
             setScriptingVars(n, VariableInfo.AT_END);
         }
 
@@ -84,9 +84,9 @@
             Vector vec = new Vector();
 
             Integer ownRange = null;
+            Node.CustomTag parent = n.getCustomTagParent();
             if (scope == VariableInfo.AT_BEGIN
                     || scope == VariableInfo.AT_END) {
-                Node.CustomTag parent = n.getCustomTagParent();
                 if (parent == null)
                     ownRange = MAX_SCOPE;
                 else
@@ -105,8 +105,11 @@
                     String varName = varInfos[i].getVarName();
                     
                     Integer currentRange = (Integer) scriptVars.get(varName);
-                    if (currentRange == null
-                            || ownRange.compareTo(currentRange) > 0) {
+                    // If a fragment helper has been used for the parent tag
+                    // the scripting variables always need to be declared
+                    if (currentRange == null ||
+                            ownRange.compareTo(currentRange) > 0 ||
+                            parent != null && isImplemetedAsFragment(parent)) {
                         scriptVars.put(varName, ownRange);
                         vec.add(varInfos[i]);
                     }
@@ -128,10 +131,13 @@
                     }
 
                     Integer currentRange = (Integer) scriptVars.get(varName);
-                    if (currentRange == null
-                            || ownRange.compareTo(currentRange) > 0) {
+                    // If a fragment helper has been used for the parent tag
+                    // the scripting variables always need to be declared
+                    if (currentRange == null ||
+                            ownRange.compareTo(currentRange) > 0 ||
+                            parent != null && isImplemetedAsFragment(parent)) {
                         scriptVars.put(varName, ownRange);
-                        vec.add(tagVarInfos[i]);
+                        vec.add(varInfos[i]);
                     }
                 }
             }
@@ -140,6 +146,22 @@
         }
     }
 
+    private static boolean isImplemetedAsFragment(Node.CustomTag n) {
+        // Replicates logic from Generator to determine if a fragment
+        // helper will be used
+        if (n.implementsSimpleTag()) {
+            if (Generator.findJspBody(n) == null) {
+                if (!n.hasEmptyBody()) {
+                    return true;
+                }
+                return false;
+            }
+            return true;
+        }
+        return false;
+    }
+
+
     public static void set(Node.Nodes page, ErrorDispatcher err)
             throws JasperException {
         page.visit(new CustomTagCounter());



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message