JSP 2.2 - Add omit attribute to <jsp:attribute>
authormarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Wed, 23 Dec 2009 20:05:25 +0000 (20:05 +0000)
committermarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Wed, 23 Dec 2009 20:05:25 +0000 (20:05 +0000)
git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@893617 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/jasper/compiler/Generator.java
java/org/apache/jasper/compiler/Node.java
java/org/apache/jasper/compiler/Validator.java

index a0e11aa..18c5bfb 100644 (file)
@@ -1950,6 +1950,10 @@ class Generator {
             for (int i = 0; attrs != null && i < attrs.length; i++) {
                 String attrStr = null;
                 if (attrs[i].isNamedAttribute()) {
+                    if (attrs[i].getNamedAttributeNode().isOmit()) {
+                        // Skip this attribute - JSP.5-7
+                        continue;
+                    }
                     attrStr = generateNamedAttributeValue(attrs[i]
                             .getNamedAttributeNode());
                 } else {
index 2388815..1f0852c 100644 (file)
@@ -1864,6 +1864,10 @@ abstract class Node implements TagConstants {
         // True if this node is to be trimmed, or false otherwise
         private boolean trim = true;
 
+        // True if this attribute should be omitted from the output if
+        // used with a <jsp:element>, otherwise false
+        private boolean omit = false;
+
         private ChildInfo childInfo;
 
         private String name;
@@ -1886,6 +1890,10 @@ abstract class Node implements TagConstants {
                 // (if null or true, leave default of true)
                 trim = false;
             }
+            if ("true".equals(this.getAttributeValue("omit"))) {
+                // (if null or false, leave default of false)
+                omit = true;
+            }
             childInfo = new ChildInfo();
             name = this.getAttributeValue("name");
             if (name != null) {
@@ -1925,6 +1933,10 @@ abstract class Node implements TagConstants {
             return trim;
         }
 
+        public boolean isOmit() {
+            return omit;
+        }
+
         /**
          * @return A unique temporary variable name to store the result in.
          *         (this probably could go elsewhere, but it's convenient here)
index f9035e8..2474456 100644 (file)
@@ -482,7 +482,8 @@ class Validator {
 
         private static final JspUtil.ValidAttribute[] attributeAttrs = {
                 new JspUtil.ValidAttribute("name", true),
-                new JspUtil.ValidAttribute("trim") };
+                new JspUtil.ValidAttribute("trim"),
+                new JspUtil.ValidAttribute("omit")};
 
         private static final JspUtil.ValidAttribute[] invokeAttrs = {
                 new JspUtil.ValidAttribute("fragment", true),