Author: gvanmatre
Date: Fri Oct 14 21:22:19 2005
New Revision: 321288

URL: http://svn.apache.org/viewcvs?rev=321288&view=rev
Log:
Modified menu builders to remove any child HTML "select" nodes that are not an 
"option" node.

Modified:
    
struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/parser/builder/SelectManyMenuBuilder.java
    
struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/parser/builder/SelectOneMenuBuilder.java

Modified: 
struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/parser/builder/SelectManyMenuBuilder.java
URL: 
http://svn.apache.org/viewcvs/struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/parser/builder/SelectManyMenuBuilder.java?rev=321288&r1=321287&r2=321288&view=diff
==============================================================================
--- 
struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/parser/builder/SelectManyMenuBuilder.java
 (original)
+++ 
struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/parser/builder/SelectManyMenuBuilder.java
 Fri Oct 14 21:22:19 2005
@@ -18,8 +18,13 @@
 
 package org.apache.shale.clay.parser.builder;
 
+import java.util.ArrayList;
+import java.util.Iterator;
+
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.shale.clay.config.beans.ComponentBean;
+import org.apache.shale.clay.config.beans.ElementBean;
 import org.apache.shale.clay.parser.Node;
 
 /**
@@ -73,5 +78,26 @@
         return true;
     }
     
-       
+    
+    /**
+     * <p>Remove any child nodes that are not "option" nodes.</p>
+     */
+    protected void encodeBegin(Node node, ElementBean target, ComponentBean 
root) {
+
+        //remove any children that are not option nodes
+        ArrayList delList = new ArrayList();
+        Iterator ci = node.getChildren().iterator();
+        while (ci.hasNext()) {
+           Node child = (Node) ci.next();
+           if (child.getName() == null || 
!child.getName().equalsIgnoreCase("option"))
+              delList.add(child);
+        }
+        for (int i = 0; i < delList.size(); i++) 
+           node.getChildren().remove(delList.get(i));
+        delList.clear();
+        
+        super.encodeBegin(node, target, root);
+    }
+
+    
 }

Modified: 
struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/parser/builder/SelectOneMenuBuilder.java
URL: 
http://svn.apache.org/viewcvs/struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/parser/builder/SelectOneMenuBuilder.java?rev=321288&r1=321287&r2=321288&view=diff
==============================================================================
--- 
struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/parser/builder/SelectOneMenuBuilder.java
 (original)
+++ 
struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/parser/builder/SelectOneMenuBuilder.java
 Fri Oct 14 21:22:19 2005
@@ -18,8 +18,13 @@
 
 package org.apache.shale.clay.parser.builder;
 
+import java.util.ArrayList;
+import java.util.Iterator;
+
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.shale.clay.config.beans.ComponentBean;
+import org.apache.shale.clay.config.beans.ElementBean;
 import org.apache.shale.clay.parser.Node;
 
 /**
@@ -72,6 +77,27 @@
      */    
     public boolean isChildrenAllowed() {
         return true;
+    }
+
+
+    /**
+     * <p>Remove any child nodes that are not "option" nodes.</p>
+     */
+    protected void encodeBegin(Node node, ElementBean target, ComponentBean 
root) {
+
+        //remove any children that are not option nodes
+        ArrayList delList = new ArrayList();
+        Iterator ci = node.getChildren().iterator();
+        while (ci.hasNext()) {
+           Node child = (Node) ci.next();
+           if (child.getName() == null || 
!child.getName().equalsIgnoreCase("option"))
+              delList.add(child);
+        }
+        for (int i = 0; i < delList.size(); i++) 
+           node.getChildren().remove(delList.get(i));
+        delList.clear();
+        
+        super.encodeBegin(node, target, root);
     }
   
     



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to