Author: gvanmatre
Date: Mon Jun 12 19:35:12 2006
New Revision: 413789

URL: http://svn.apache.org/viewvc?rev=413789&view=rev
Log:
Fix for issue SHALE-187

Added:
    
struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/config/beans/AbstractBean.java
   (with props)
    
struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/config/beans/SymbolBean.java
   (with props)
    
struts/shale/trunk/clay-plugin/src/test/org/apache/shale/clay/config/DesigntimeTestCase.java
   (with props)
Modified:
    
struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/component/Clay.java
    
struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/component/chain/AbstractCommand.java
    
struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/config/ClayXmlParser.java
    
struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/config/beans/AttributeBean.java
    
struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/config/beans/ComponentBean.java
    
struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/config/beans/ComponentConfigBean.java
    
struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/parser/builder/Builder.java
    
struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/parser/builder/ElementBuilder.java
    
struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/parser/builder/JsfDefaultBuilder.java
    
struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/taglib/SymbolTag.java
    
struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/utils/ClayAmalgam.java
    
struts/shale/trunk/clay-plugin/src/test/org/apache/shale/clay/config/SymbolsTestCase.java

Modified: 
struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/component/Clay.java
URL: 
http://svn.apache.org/viewvc/struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/component/Clay.java?rev=413789&r1=413788&r2=413789&view=diff
==============================================================================
--- 
struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/component/Clay.java
 (original)
+++ 
struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/component/Clay.java
 Mon Jun 12 19:35:12 2006
@@ -28,7 +28,6 @@
 import javax.faces.component.UINamingContainer;
 import javax.faces.context.FacesContext;
 import javax.faces.el.MethodBinding;
-import javax.faces.el.ValueBinding;
 
 import org.apache.commons.chain.Catalog;
 import org.apache.commons.chain.CatalogFactory;
@@ -43,6 +42,7 @@
 import org.apache.shale.clay.config.beans.ComponentBean;
 import org.apache.shale.clay.config.beans.ConfigBean;
 import org.apache.shale.clay.config.beans.ConfigBeanFactory;
+import org.apache.shale.clay.config.beans.SymbolBean;
 import org.apache.shale.util.Messages;
 
 /**
@@ -212,7 +212,8 @@
      * </p>
      */
     public String getManagedBeanName() {
-        return (String) symbols.get(Globals.MANAGED_BEAN_MNEMONIC);
+        SymbolBean symbol = (SymbolBean) 
symbols.get(Globals.MANAGED_BEAN_MNEMONIC);    
+        return ((symbol != null) ? symbol.getValue() : null);
     }
     
     /**
@@ -222,7 +223,10 @@
      * </p>
      */
     public void setManagedBeanName(String mbeanMnemonic) {
-        symbols.put(Globals.MANAGED_BEAN_MNEMONIC, mbeanMnemonic);
+        SymbolBean symbol = new SymbolBean();
+        symbol.setName(Globals.MANAGED_BEAN_MNEMONIC);
+        symbol.setValue(mbeanMnemonic);
+        symbols.put(symbol.getName(), symbol);
     }
     
     /**

Modified: 
struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/component/chain/AbstractCommand.java
URL: 
http://svn.apache.org/viewvc/struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/component/chain/AbstractCommand.java?rev=413789&r1=413788&r2=413789&view=diff
==============================================================================
--- 
struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/component/chain/AbstractCommand.java
 (original)
+++ 
struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/component/chain/AbstractCommand.java
 Mon Jun 12 19:35:12 2006
@@ -28,6 +28,7 @@
 import org.apache.commons.chain.Context;
 import org.apache.commons.chain.config.ConfigParser;
 import org.apache.shale.clay.config.Globals;
+import org.apache.shale.clay.config.beans.SymbolBean;
 import org.apache.shale.util.Messages;
 
 /**
@@ -102,8 +103,9 @@
         int i = buff.indexOf("@");
         replace: while (i > -1 && si.hasNext()) {
             Map.Entry e = (Map.Entry) si.next();
-            String key = (String) e.getKey();
-            String value = (String) (e.getValue() == null ? "" : e.getValue());
+            SymbolBean symbol = (SymbolBean) e.getValue();
+            String key = symbol.getName();
+            String value = (symbol.getValue() == null ? "" : 
symbol.getValue());
             i = (wasReplacementMade ? buff.indexOf("@") : i);
             if (i == -1)
               break replace;

Modified: 
struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/config/ClayXmlParser.java
URL: 
http://svn.apache.org/viewvc/struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/config/ClayXmlParser.java?rev=413789&r1=413788&r2=413789&view=diff
==============================================================================
--- 
struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/config/ClayXmlParser.java
 (original)
+++ 
struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/config/ClayXmlParser.java
 Mon Jun 12 19:35:12 2006
@@ -101,38 +101,6 @@
         
     
     /**
-     * <p>This is a custom digester Rule that handles adding value pairs to 
-     * the symbols table on the [EMAIL PROTECTED] ComponentBean} nodes.</p>
-     */
-    private class SymbolRule extends Rule {
-
-        /**
-         * <p>Takes a peek at the last object on the digester stack.
-         * It assume that it will be a [EMAIL PROTECTED] ComponentBean}.  The
-         * attributes "name" and "value" are pulled
-         * from the <code>Attributes</code> sax collection and pushed
-         * into the [EMAIL PROTECTED] ComponentBean}'s <code>symbols</code> Map
-         * collection.  The character '@' is prepended to the symbol
-         * name if not existing.</p>  
-         */
-        public void begin(String qname, String name, Attributes attributes) 
throws Exception {
-           ComponentBean b = (ComponentBean) super.digester.peek();
-           if (b != null && attributes != null) {
-                 String key = attributes.getValue("name");
-                 String value = attributes.getValue("value");
-                 if (name != null) {
-                    StringBuffer tmp = new StringBuffer(key);
-                    if (tmp.charAt(0) != '@')
-                      tmp.insert(0, '@');
-                        
-                    b.addSymbol(tmp.toString(), value);    
-                 }
-           }
-        }
-       
-    }
-
-    /**
      * <p>Loads a configuration file from a <code>url</code>.  The
      * input stream is identifed by the <code>watchDogName</code>.</p>
      */
@@ -186,6 +154,11 @@
             if (log.isInfoEnabled())
                 log.info(messages.getMessage("parser.load.rules"));
             
+            if (getConfig() instanceof ComponentConfigBean) {
+                if (((ComponentConfigBean) getConfig()).isDesigntime())
+                    digester.addBeanPropertySetter("*/description", 
"description");
+            }
+            
             digester.addObjectCreate(
                     "*/attributes/set",
                     org.apache.shale.clay.config.beans.AttributeBean.class);
@@ -195,7 +168,14 @@
                     "addAttribute",
                     "org.apache.shale.clay.config.beans.AttributeBean");
             
-            digester.addRule("*/symbols/set", new SymbolRule());
+            digester.addObjectCreate(
+                    "*/symbols/set",
+                    org.apache.shale.clay.config.beans.SymbolBean.class);
+            digester.addSetProperties("*/symbols/set");
+            digester.addSetNext(
+                    "*/symbols/set",
+                    "addSymbol",
+                    "org.apache.shale.clay.config.beans.SymbolBean");
             
             digester.addObjectCreate(
                     "*/valueChangeListener",

Added: 
struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/config/beans/AbstractBean.java
URL: 
http://svn.apache.org/viewvc/struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/config/beans/AbstractBean.java?rev=413789&view=auto
==============================================================================
--- 
struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/config/beans/AbstractBean.java
 (added)
+++ 
struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/config/beans/AbstractBean.java
 Mon Jun 12 19:35:12 2006
@@ -0,0 +1,48 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * $Id$
+ */
+
+
+package org.apache.shale.clay.config.beans;
+
+/**
+ * <p>Abstract class that provides a <code>description</code> property 
+ * that is populated from the clay configuration file 
+ * when design time tool support is enabled.</p> 
+ *
+ */
+public abstract class AbstractBean {
+    /**
+     * <p>Metadata description provided in the clay configuration.</p>
+     */
+    private String description = null;
+
+    /**
+     * <p>Returns the <code>description</code> of the bean.</p>
+     */
+    public String getDescription() {
+        return description;
+    }
+
+    /**
+     * <p>Sets the <code>description</code> of the bean.</p>
+     */    
+    public void setDescription(String description) {
+        this.description = description;
+    }
+    
+}

Propchange: 
struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/config/beans/AbstractBean.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/config/beans/AbstractBean.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Modified: 
struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/config/beans/AttributeBean.java
URL: 
http://svn.apache.org/viewvc/struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/config/beans/AttributeBean.java?rev=413789&r1=413788&r2=413789&view=diff
==============================================================================
--- 
struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/config/beans/AttributeBean.java
 (original)
+++ 
struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/config/beans/AttributeBean.java
 Mon Jun 12 19:35:12 2006
@@ -18,16 +18,13 @@
 
 package org.apache.shale.clay.config.beans;
 
-import java.io.Serializable;
 
 /**
  * <p>Represents a value for a component property or a tag attribute.
  * Instances of this class will be placed in the [EMAIL PROTECTED] 
ComponentBean}
  * <code>attributes</code> collection.</p>
  */
-public class AttributeBean implements Comparable, Serializable {
-
-    private static final long serialVersionUID = 3689352130423305014L;
+public class AttributeBean extends SymbolBean {
 
     /**
      * <p>Mnemonic the signifies the a method binding expression.</p>
@@ -51,18 +48,7 @@
      * be preformed.</p>
      */
     public static final String BINDING_TYPE_NONE = "None";
-    
-    
-    /**
-     * <p>Name of the attribute in the target JSF object property.</p>
-     */    
-    private String name = null;
-
-    /**
-     * <p>Value of the named attribute in the target JSF object property.</p>
-     */
-    private String value = null;
-   
+       
     /**
      * <p>The parent meta component that contains this attribute in its
      * attributes collection.
@@ -95,49 +81,11 @@
          */
     public String toString() {
         StringBuffer buff = new StringBuffer();
-        buff.append("name=\"").append(name).append("\" value=\"").append(value)
+        buff.append("name=\"").append(getName()).append("\" 
value=\"").append(getValue())
             .append("\" bindingType=\"").append(bindingType).append("\"");
         return buff.toString();
     }
  
-    /**
-     * <p>Returns a name corresponding to an associated JSF object 
property.</p>
-     */
-    public String getName() {
-        return name;
-    }
-
-    /**
-     * <p>Returns the value of the attribute that can be a literal or a
-     * expression.</p>
-     */
-    public String getValue() {
-        return value;
-    }
-
-    /**
-     * <p>Sets the name of the attribute.</p>
-     */    
-    public void setName(String string) {
-        name = string;
-    }
-
-    /**
-     * <p>Sets the value of the attribute.</p>
-     */    
-    public void setValue(String string) {
-        value = string;
-    }
-   
-    /**
-     * <p>This implementation of the <code>Comparable</code> interface makes
-     * the <code>name</code> property the compared key.</p>
-     */
-    public int compareTo(Object obj) {
-        AttributeBean item = (AttributeBean) obj;
-        
-        return item.getName().compareTo(getName());
-    }
     
     /**
      * <p>Returns the parent component containing this object instance.</p>

Modified: 
struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/config/beans/ComponentBean.java
URL: 
http://svn.apache.org/viewvc/struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/config/beans/ComponentBean.java?rev=413789&r1=413788&r2=413789&view=diff
==============================================================================
--- 
struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/config/beans/ComponentBean.java
 (original)
+++ 
struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/config/beans/ComponentBean.java
 Mon Jun 12 19:35:12 2006
@@ -22,7 +22,6 @@
 import java.util.Collection;
 import java.util.Iterator;
 import java.util.Map;
-import java.util.TreeMap;
 import java.util.TreeSet;
 
 import org.apache.commons.logging.Log;
@@ -43,7 +42,7 @@
  * </dl>
  * </p>
  */
-public class ComponentBean implements Comparable, Serializable {
+public class ComponentBean extends AbstractBean implements Comparable, 
Serializable {
     
     private static final long serialVersionUID = 3907217039524312373L;
 
@@ -649,12 +648,19 @@
     }
     
     /**
-     * <p>Adds a symbol identified by the <code>key</code>
-     * and replacement <code>value</code> to the symbols 
-     * collection.</p>  
+     * <p>Adds a symbol identified by the 
+     * [EMAIL PROTECTED] SymbolBean} to the symbols collection.</p>  
      */
-    public void addSymbol(String key, String value) {
-       symbols.put(key, value);     
+    public void addSymbol(SymbolBean symbol) {
+       if (symbol.getName() != null && symbol.getName().length() > 0) {
+            StringBuffer buff = new StringBuffer(symbol.getName());
+            if (buff.charAt(0) != '@') { 
+               buff.insert(0, '@');
+               symbol.setName(buff.toString());
+            }
+     
+            symbols.put(symbol.getName(), symbol);
+        }
     }
     
     /**
@@ -664,6 +670,22 @@
      */
     public Map getSymbols() {
        return symbols;    
+    }
+    
+    
+    /**
+     * <p>Returns a [EMAIL PROTECTED] SymbolBean} from the <code>symbols</code>
+     * Map by <code>name</code>.  Prepends a '@' character to the 
+     * <code>name</code> if it doesn't exist.</p>  
+     */
+    public SymbolBean getSymbol(String name) {
+        StringBuffer tmp = new StringBuffer(name);
+        if (tmp.charAt(0) != '@')
+            tmp.insert(0, '@');
+        
+        SymbolBean symbol = (SymbolBean) symbols.get(tmp.toString());
+        
+        return symbol;
     }
     
 }

Modified: 
struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/config/beans/ComponentConfigBean.java
URL: 
http://svn.apache.org/viewvc/struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/config/beans/ComponentConfigBean.java?rev=413789&r1=413788&r2=413789&view=diff
==============================================================================
--- 
struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/config/beans/ComponentConfigBean.java
 (original)
+++ 
struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/config/beans/ComponentConfigBean.java
 Mon Jun 12 19:35:12 2006
@@ -103,6 +103,32 @@
      */
     protected transient ServletContext context = null;
     
+    
+    /**
+     * <p>Flag that indicates the current mode is design time.
+     * In design time mode, the descriptions in the clay
+     * configuration files will populate the <code>description</code>
+     * property of the target [EMAIL PROTECTED] AbstractBean}.</p>
+     */
+    private boolean isDesigntime = false;
+    
+    /**
+     * <p>Returns <code>true</code> if the current mode
+     * is design time.</p>
+     */
+    public boolean isDesigntime() {
+       return isDesigntime;
+    }
+    
+    /**
+     * <p>Sets the design time to somthing other than
+     * the default <code>false</code> value.</p>
+     */
+    public void setDesigntime(boolean isDesigntime) {
+       this.isDesigntime = isDesigntime;
+    }
+    
+    
     /**
      * <p>Initialization method that is passed the <code>ServletContext</code>
      * as a parameter.  Loads the <code>sufixes</code> for the ServletContext 
@@ -482,6 +508,9 @@
         // inherit late binding type
         if (a.getBindingType() == null)
             a.setBindingType(a.getIsAParent().getBindingType());
+        
+        if (a.getDescription() == null) 
+            a.setDescription(a.getIsAParent().getDescription());
                 
         // set final indicator
         a.setInheritanceFinal(true);
@@ -517,6 +546,9 @@
 
             if (b.getFacetName() == null)
                 b.setFacetName(b.getIsAParent().getFacetName());
+            
+            if (b.getDescription() == null)
+                b.setDescription(b.getIsAParent().getDescription());
 
             // inherit parents attributes
             Iterator pi = b.getIsAParent().getAttributeIterator();

Added: 
struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/config/beans/SymbolBean.java
URL: 
http://svn.apache.org/viewvc/struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/config/beans/SymbolBean.java?rev=413789&view=auto
==============================================================================
--- 
struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/config/beans/SymbolBean.java
 (added)
+++ 
struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/config/beans/SymbolBean.java
 Mon Jun 12 19:35:12 2006
@@ -0,0 +1,92 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * $Id$
+ */
+
+package org.apache.shale.clay.config.beans;
+
+import java.io.Serializable;
+
+/**
+ * <p>A symbol represents a variable replaced in a 
+ * JSF binding expression.  Within the expression 
+ * symbols are identified by the '@' prefix.</p>  
+ *
+ */
+public class SymbolBean extends AbstractBean implements Serializable,
+        Comparable {
+
+    private static final long serialVersionUID = -584466364674399355L;
+
+    /**
+     * <p>Name of the symbol in the target JSF object property.</p>
+     */    
+    private String name = null;
+
+    /**
+     * <p>Value of the named symbol in the target JSF object property.</p>
+     */
+    private String value = null;
+   
+
+    /**
+     * <p>Returns a name corresponding to an associated JSF object 
property.</p>
+     */
+    public String getName() {
+        return name;
+    }
+
+    /**
+     * <p>Returns the value of the attribute that can be a literal or a
+     * expression.</p>
+     */
+    public String getValue() {
+        return value;
+    }
+
+    /**
+     * <p>Sets the name of the attribute.</p>
+     */    
+    public void setName(String string) {
+        name = string;
+    }
+
+    /**
+     * <p>Sets the value of the attribute.</p>
+     */    
+    public void setValue(String string) {
+        value = string;
+    }
+   
+    /**
+     * <p>This implementation of the <code>Comparable</code> interface makes
+     * the <code>name</code> property the compared key.</p>
+     */
+    public int compareTo(Object obj) {
+        SymbolBean item = (SymbolBean) obj;
+        
+        return item.getName().compareTo(getName());
+    }
+   
+        
+    public String toString() {
+        StringBuffer buff = new StringBuffer();
+        buff.append("name=\"").append(name).append("\" value=\"").append(value)
+            .append("\"");
+        return buff.toString();
+    }
+
+}

Propchange: 
struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/config/beans/SymbolBean.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/config/beans/SymbolBean.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Modified: 
struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/parser/builder/Builder.java
URL: 
http://svn.apache.org/viewvc/struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/parser/builder/Builder.java?rev=413789&r1=413788&r2=413789&view=diff
==============================================================================
--- 
struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/parser/builder/Builder.java
 (original)
+++ 
struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/parser/builder/Builder.java
 Mon Jun 12 19:35:12 2006
@@ -28,6 +28,7 @@
 import org.apache.shale.clay.config.beans.ConfigBean;
 import org.apache.shale.clay.config.beans.ConfigBeanFactory;
 import org.apache.shale.clay.config.beans.ElementBean;
+import org.apache.shale.clay.config.beans.SymbolBean;
 import org.apache.shale.clay.parser.Node;
 import org.apache.shale.clay.parser.Token;
 import org.apache.shale.util.Messages;
@@ -310,7 +311,10 @@
                     //any token that is not an attribute in the target becomes 
a symbol
                     StringBuffer identifier = new StringBuffer((String) 
e.getKey());
                     identifier.insert(0, '@');
-                    target.addSymbol(identifier.toString(), 
valueToken.getRawText()); 
+                    SymbolBean symbol = new SymbolBean();
+                    symbol.setName(identifier.toString());
+                    symbol.setValue(valueToken.getRawText());
+                    target.addSymbol(symbol); 
                 }
             }    
         }

Modified: 
struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/parser/builder/ElementBuilder.java
URL: 
http://svn.apache.org/viewvc/struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/parser/builder/ElementBuilder.java?rev=413789&r1=413788&r2=413789&view=diff
==============================================================================
--- 
struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/parser/builder/ElementBuilder.java
 (original)
+++ 
struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/parser/builder/ElementBuilder.java
 Mon Jun 12 19:35:12 2006
@@ -31,6 +31,7 @@
 import org.apache.shale.clay.config.beans.ConfigBeanFactory;
 import org.apache.shale.clay.config.beans.ConverterBean;
 import org.apache.shale.clay.config.beans.ElementBean;
+import org.apache.shale.clay.config.beans.SymbolBean;
 import org.apache.shale.clay.config.beans.ValidatorBean;
 import org.apache.shale.clay.config.beans.ValueChangeListenerBean;
 import org.apache.shale.clay.parser.Node;
@@ -225,8 +226,16 @@
                 String name = (String) child.getAttributes().get("name");
                 String value = (String) child.getAttributes().get("value");
                 
-                if (name != null && name.length() > 0)
-                    target.addSymbol(name, value);
+                if (name != null && name.length() > 0) {
+                    SymbolBean symbol = new SymbolBean();
+                    StringBuffer tmp = new StringBuffer(name);
+                    if (tmp.charAt(0) != '@')
+                       tmp.insert(0, '@');
+                    
+                    symbol.setName(tmp.toString());
+                    symbol.setValue(value);
+                    target.addSymbol(symbol);
+                }
             }
         }
     }

Modified: 
struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/parser/builder/JsfDefaultBuilder.java
URL: 
http://svn.apache.org/viewvc/struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/parser/builder/JsfDefaultBuilder.java?rev=413789&r1=413788&r2=413789&view=diff
==============================================================================
--- 
struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/parser/builder/JsfDefaultBuilder.java
 (original)
+++ 
struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/parser/builder/JsfDefaultBuilder.java
 Mon Jun 12 19:35:12 2006
@@ -26,6 +26,7 @@
 import org.apache.shale.clay.config.beans.ComponentBean;
 import org.apache.shale.clay.config.beans.ConverterBean;
 import org.apache.shale.clay.config.beans.ElementBean;
+import org.apache.shale.clay.config.beans.SymbolBean;
 import org.apache.shale.clay.config.beans.ValidatorBean;
 import org.apache.shale.clay.config.beans.ValueChangeListenerBean;
 import org.apache.shale.clay.parser.Node;
@@ -159,8 +160,15 @@
     protected void addSymbol(Node node, ElementBean target) {
         String value = (String) node.getAttributes().get("value");
         String name = (String) node.getAttributes().get("name");
-        if (name != null) {
-            target.addSymbol(name, value);    
+        if (name != null && name.length() > 0) {
+            SymbolBean symbol = new SymbolBean();
+            StringBuffer tmp = new StringBuffer(name);
+            if (tmp.charAt(0) != '@')
+               tmp.insert(0, '@');
+            
+            symbol.setName(tmp.toString());
+            symbol.setValue(value);
+            target.addSymbol(symbol);    
         }
     }
 

Modified: 
struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/taglib/SymbolTag.java
URL: 
http://svn.apache.org/viewvc/struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/taglib/SymbolTag.java?rev=413789&r1=413788&r2=413789&view=diff
==============================================================================
--- 
struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/taglib/SymbolTag.java
 (original)
+++ 
struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/taglib/SymbolTag.java
 Mon Jun 12 19:35:12 2006
@@ -21,6 +21,7 @@
 import javax.servlet.jsp.tagext.TagSupport;
 
 import org.apache.shale.clay.component.Clay;
+import org.apache.shale.clay.config.beans.SymbolBean;
 import org.apache.shale.util.Messages;
 
 /**
@@ -108,7 +109,10 @@
           if (tmp.charAt(0) != '@')
             tmp.insert(0, '@');
           
-          clayParent.getSymbols().put(tmp.toString(), value);          
+          SymbolBean symbol = new SymbolBean();
+          symbol.setName(tmp.toString());
+          symbol.setValue(value);
+          clayParent.getSymbols().put(symbol.getName(), symbol.getValue());    
      
           
           return super.doStartTag();
     

Modified: 
struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/utils/ClayAmalgam.java
URL: 
http://svn.apache.org/viewvc/struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/utils/ClayAmalgam.java?rev=413789&r1=413788&r2=413789&view=diff
==============================================================================
--- 
struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/utils/ClayAmalgam.java
 (original)
+++ 
struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/utils/ClayAmalgam.java
 Mon Jun 12 19:35:12 2006
@@ -38,6 +38,7 @@
 import org.apache.shale.clay.config.beans.ConfigBean;
 import org.apache.shale.clay.config.beans.ConfigBeanFactory;
 import org.apache.shale.clay.config.beans.ElementBean;
+import org.apache.shale.clay.config.beans.SymbolBean;
 import org.apache.shale.faces.ShaleConstants;
 import org.apache.shale.util.Messages;
 import org.apache.shale.util.Tags;
@@ -418,7 +419,10 @@
 
               //prepend the var to the generated key
               id.insert(0, var + "."); 
-              target.addSymbol(Globals.MANAGED_BEAN_MNEMONIC, id.toString());
+              SymbolBean symbol = new SymbolBean();
+              symbol.setName(Globals.MANAGED_BEAN_MNEMONIC);
+              symbol.setValue(id.toString());
+              target.addSymbol(symbol);
               
               
               namingContainer.addChild(target);

Added: 
struts/shale/trunk/clay-plugin/src/test/org/apache/shale/clay/config/DesigntimeTestCase.java
URL: 
http://svn.apache.org/viewvc/struts/shale/trunk/clay-plugin/src/test/org/apache/shale/clay/config/DesigntimeTestCase.java?rev=413789&view=auto
==============================================================================
--- 
struts/shale/trunk/clay-plugin/src/test/org/apache/shale/clay/config/DesigntimeTestCase.java
 (added)
+++ 
struts/shale/trunk/clay-plugin/src/test/org/apache/shale/clay/config/DesigntimeTestCase.java
 Mon Jun 12 19:35:12 2006
@@ -0,0 +1,131 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.shale.clay.config;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.apache.shale.clay.config.beans.AttributeBean;
+import org.apache.shale.clay.config.beans.ComponentBean;
+import org.apache.shale.clay.config.beans.ComponentConfigBean;
+import org.apache.shale.clay.config.beans.SymbolBean;
+
+public class DesigntimeTestCase extends AbstractTestCaseConfig {
+
+    // Construct a new instance of this test case.
+    public DesigntimeTestCase(String name) {
+        super(name);
+    }
+
+    // Return the tests included in this test case.
+    public static Test suite() {
+
+        return (new TestSuite(DesigntimeTestCase.class));
+
+    }
+
+    public void setUp() {
+        super.setUp();
+    }
+
+    public void testDesigntimeOn() {
+        ((ComponentConfigBean) standardConfigBean).setDesigntime(true);       
+        loadConfigFiles(null, null);
+        
+        ComponentBean bean = standardConfigBean.getElement("clay");
+        assertNotNull(bean);
+        
+        String description = bean.getDescription();
+        assertNotNull(description);
+        
+        assertTrue(description.startsWith("This component builds a sub 
component tree and attaches"));
+        
+        AttributeBean attr = bean.getAttribute("managedBeanName");
+        assertNotNull(attr);
+        
+        description = attr.getDescription();
+        assertEquals("A symbol that is used to alias the bound backing bean.", 
description);
+
+        
+        bean = standardConfigBean.getElement("baseHtml");
+        assertNotNull(bean);
+        
+        description = bean.getDescription();
+        assertNotNull(description);
+        
+        assertTrue(description.startsWith("Abstract base component 
definition"));
+        
+        SymbolBean symbol = (SymbolBean) bean.getSymbols().get("@class");
+        assertNotNull(symbol);
+        
+        description = symbol.getDescription();
+        assertNotNull(description);
+        
+        assertEquals("The default value of the styleClass attribute.", 
description);
+        
+        
+    }
+
+    
+    public void testDesigntimeOff() {
+        ((ComponentConfigBean) standardConfigBean).setDesigntime(false);       
+        loadConfigFiles(null, null);
+        
+        ComponentBean bean = standardConfigBean.getElement("clay");
+        assertNotNull(bean);
+        
+        String description = bean.getDescription();
+        assertNull(description);
+               
+        AttributeBean attr = bean.getAttribute("managedBeanName");
+        assertNotNull(attr);
+        
+        description = attr.getDescription();
+        assertNull(description);
+
+        bean = standardConfigBean.getElement("baseHtml");
+        assertNotNull(bean);
+        
+        description = bean.getDescription();
+        assertNull(description);
+
+        SymbolBean symbol = (SymbolBean) bean.getSymbols().get("@class");
+        assertNotNull(symbol);
+        
+        description = symbol.getDescription();
+        assertNull(description);
+        
+    }
+
+
+    public void testDesigntimeOnInheritance() {
+        ((ComponentConfigBean) standardConfigBean).setDesigntime(true);       
+        loadConfigFiles(null, null);
+
+        ComponentBean bean1 = standardConfigBean.getElement("f:converter");
+        assertNotNull(bean1);
+        
+        assertNotNull(bean1.getDescription());
+        
+        ComponentBean bean2 = 
standardConfigBean.getElement(bean1.getExtends());
+        assertNotNull(bean2);
+
+        assertNotNull(bean2.getDescription());
+        assertEquals(bean2.getDescription(), bean1.getDescription());
+
+    }     
+        
+}

Propchange: 
struts/shale/trunk/clay-plugin/src/test/org/apache/shale/clay/config/DesigntimeTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
struts/shale/trunk/clay-plugin/src/test/org/apache/shale/clay/config/DesigntimeTestCase.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Modified: 
struts/shale/trunk/clay-plugin/src/test/org/apache/shale/clay/config/SymbolsTestCase.java
URL: 
http://svn.apache.org/viewvc/struts/shale/trunk/clay-plugin/src/test/org/apache/shale/clay/config/SymbolsTestCase.java?rev=413789&r1=413788&r2=413789&view=diff
==============================================================================
--- 
struts/shale/trunk/clay-plugin/src/test/org/apache/shale/clay/config/SymbolsTestCase.java
 (original)
+++ 
struts/shale/trunk/clay-plugin/src/test/org/apache/shale/clay/config/SymbolsTestCase.java
 Mon Jun 12 19:35:12 2006
@@ -29,6 +29,7 @@
 import org.apache.shale.clay.config.beans.AttributeBean;
 import org.apache.shale.clay.config.beans.ComponentBean;
 import org.apache.shale.clay.config.beans.ElementBean;
+import org.apache.shale.clay.config.beans.SymbolBean;
 import org.apache.shale.faces.ShaleConstants;
 import org.apache.shale.util.Tags;
 
@@ -92,7 +93,7 @@
 
        isFinal = command.execute(clayContext);
        assertEquals("command finished", isFinal, true);       
-       assertEquals("value = 1969", child.getValue(), "1969");
+       assertEquals("value = 1969", "1969", child.getValue());
        
        child = (javax.faces.component.html.HtmlOutputText) 
                              
facesContext.getApplication().createComponent("javax.faces.HtmlOutputText"); 
@@ -105,7 +106,7 @@
 
        isFinal = command.execute(clayContext);
        assertEquals("command finished", isFinal, true);       
-       assertEquals("value = pong", child.getValue(), "pong");
+       assertEquals("value = pong", "pong", child.getValue());
 
 
        child = (javax.faces.component.html.HtmlOutputText) 
@@ -118,10 +119,17 @@
 
        isFinal = command.execute(clayContext);
        assertEquals("command finished", isFinal, true);       
-       assertEquals("value = #{forManfred}", child.getValue(), 
"#{forManfred}");
+       assertEquals("value = #{forManfred}", "#{forManfred}", 
child.getValue());
 
         
     }
+    
+    private SymbolBean createSymbol(String name, String value) {
+       SymbolBean symbol = new SymbolBean();
+       symbol.setName(name);
+       symbol.setValue(value);
+       return symbol;
+    }
    
     // test symbolic property replacement
     public void testSymbolicProperties() throws Exception {
@@ -140,7 +148,7 @@
            displayElement.setComponentType("javax.faces.HtmlOutputText");
            displayElement.setId("testId");
            displayElement.addAttribute(attr);
-           displayElement.addSymbol("@value", "10");
+           displayElement.addSymbol(createSymbol("@value", "10"));
                       
            ClayContext clayContext = new ClayContext();
            clayContext.setFacesContext(facesContext);
@@ -155,7 +163,7 @@
            Command command = new PropertyValueCommand();
            boolean isFinal = command.execute(clayContext);
            assertEquals("command finished", isFinal, true);       
-           assertEquals("value = 10", child.getValue(), "10");
+           assertEquals("value = 10", "10", child.getValue());
 
            
            // test a symbol value of an el value
@@ -163,7 +171,7 @@
                         
facesContext.getApplication().createComponent("javax.faces.HtmlOutputText"); 
            assertNotNull("javax.faces.HtmlOutputText", child);
 
-           displayElement.addSymbol("@value", "#{value}");
+           displayElement.addSymbol(createSymbol("@value", "#{value}"));
            attr.setBindingType(AttributeBean.BINDING_TYPE_EARLY);
            servletContext.setAttribute("value", "10");
           
@@ -175,7 +183,7 @@
            
            isFinal = command.execute(clayContext);
            assertEquals("command finished", isFinal, true);       
-           assertEquals("value = 10", child.getValue(), "10");
+           assertEquals("value = 10", "10", child.getValue());
 
            
            // test a symbol value with a null value symbol replacement
@@ -183,7 +191,7 @@
                  
facesContext.getApplication().createComponent("javax.faces.HtmlOutputText"); 
            assertNotNull("javax.faces.HtmlOutputText", child);
 
-           displayElement.addSymbol("@value", null);
+           displayElement.addSymbol(createSymbol("@value", null));
            attr.setBindingType(AttributeBean.BINDING_TYPE_EARLY);
           
            clayContext.setFacesContext(facesContext);
@@ -194,7 +202,7 @@
            
            isFinal = command.execute(clayContext);
            assertEquals("command finished", isFinal, true);       
-           assertEquals("value = null", child.getValue(), null);
+           assertEquals("value = null", null, child.getValue());
 
 
            // test a symbol value with an empty String value.  
@@ -203,7 +211,7 @@
                      
facesContext.getApplication().createComponent("javax.faces.HtmlOutputText"); 
            assertNotNull("javax.faces.HtmlOutputText", child);
 
-           displayElement.addSymbol("@value", "");
+           displayElement.addSymbol(createSymbol("@value", ""));
            attr.setBindingType(AttributeBean.BINDING_TYPE_EARLY);
           
            clayContext.setFacesContext(facesContext);
@@ -214,7 +222,7 @@
            
            isFinal = command.execute(clayContext);
            assertEquals("command finished", isFinal, true);       
-           assertEquals("value = null", child.getValue(), null);
+           assertEquals("value = null", null, child.getValue());
 
            //no symbol replacement for a empty string - should return
            //an empty string.  This allows components like the selectItem
@@ -231,7 +239,7 @@
            
            isFinal = command.execute(clayContext);
            assertEquals("command finished", isFinal, true);       
-           assertEquals("value = \"\"", child.getValue(), "");
+           assertEquals("value = \"\"", "", child.getValue());
 
            //Case insensitive and reoccurring replacement
            attr.setValue("@TeSt1, @tEst1 never @test2; @test1, @teSt1 till ya 
@tesT3");  //test multiple symbols           
@@ -239,9 +247,9 @@
                      
facesContext.getApplication().createComponent("javax.faces.HtmlOutputText"); 
            assertNotNull("javax.faces.HtmlOutputText", child);
 
-           displayElement.addSymbol("@test1", "rock");
-           displayElement.addSymbol("@test2", "stop");
-           displayElement.addSymbol("@test3", "drop");
+           displayElement.addSymbol(createSymbol("@test1", "rock"));
+           displayElement.addSymbol(createSymbol("@test2", "stop"));
+           displayElement.addSymbol(createSymbol("@test3", "drop"));
 
            clayContext.setFacesContext(facesContext);
            clayContext.setChild(child);
@@ -253,7 +261,7 @@
            isFinal = command.execute(clayContext);
            assertEquals("command finished", isFinal, true);       
            assertEquals("value = \"rock, rock never stop; rock, rock till ya 
drop\"", 
-                   child.getValue(), "rock, rock never stop; rock, rock till 
ya drop");
+                   "rock, rock never stop; rock, rock till ya drop", 
child.getValue());
 
     }
 
@@ -269,7 +277,7 @@
         displayElement.setJsfid("inputText");
         displayElement.setComponentType("javax.faces.HtmlOutputText");
         displayElement.setId("@wynn");
-        displayElement.addSymbol("@wynn", "test");
+        displayElement.addSymbol(createSymbol("@wynn", "test"));
         
         ClayContext clayContext = new ClayContext();
         clayContext.setFacesContext(facesContext);
@@ -287,7 +295,7 @@
         UIComponent child = (UIComponent) clayContext.getChild();
         assertNotNull("child", child);
         
-        assertEquals("id = test", child.getId(), "test");
+        assertEquals("id = test", "test", child.getId());
         
         
         //null component id symbol replacement
@@ -300,7 +308,7 @@
         displayElement.setJsfid("inputText");
         displayElement.setComponentType("javax.faces.HtmlOutputText");
         displayElement.setId("@wynn");
-        displayElement.addSymbol("@wynn", null);
+        displayElement.addSymbol(createSymbol("@wynn", null));
         
         clayContext = new ClayContext();
         clayContext.setFacesContext(facesContext);
@@ -371,8 +379,8 @@
         displayElement.setComponentType("javax.faces.HtmlOutputText");
         displayElement.setId("testId");
         displayElement.addAttribute(attr);
-        displayElement.addSymbol("@[ab]", "43");
-        displayElement.addSymbol("@[a]", "67");
+        displayElement.addSymbol(createSymbol("@[ab]", "43"));
+        displayElement.addSymbol(createSymbol("@[a]", "67"));
              
         ClayContext clayContext = new ClayContext();
         clayContext.setFacesContext(facesContext);
@@ -388,7 +396,7 @@
         Command command = new PropertyValueCommand();
         boolean isFinal = command.execute(clayContext);
         assertEquals("command finished", isFinal, true);       
-        assertEquals("value = 6743", child.getValue(), "6743");      
+        assertEquals("value = 6743", "6743", child.getValue());      
 
     
         //create a target component
@@ -397,14 +405,14 @@
         assertNotNull("javax.faces.HtmlOutputText", child);
 
         attr.setValue("@[EMAIL PROTECTED]");  //symbolic attribute 
-        displayElement.addSymbol("@{ab}", "43");
-        displayElement.addSymbol("@{a}", "67");
+        displayElement.addSymbol(createSymbol("@{ab}", "43"));
+        displayElement.addSymbol(createSymbol("@{a}", "67"));
 
         clayContext.setChild(child);
 
         isFinal = command.execute(clayContext);
         assertEquals("command finished", isFinal, true);       
-        assertEquals("value = 6743", child.getValue(), "6743");      
+        assertEquals("value = 6743", "6743", child.getValue());      
 
 
         
@@ -414,14 +422,14 @@
         assertNotNull("javax.faces.HtmlOutputText", child);
 
         attr.setValue("@(a)@(ab)");  //symbolic attribute 
-        displayElement.addSymbol("@(ab)", "43");
-        displayElement.addSymbol("@(a)", "67");
+        displayElement.addSymbol(createSymbol("@(ab)", "43"));
+        displayElement.addSymbol(createSymbol("@(a)", "67"));
 
         clayContext.setChild(child);
 
         isFinal = command.execute(clayContext);
         assertEquals("command finished", isFinal, true);       
-        assertEquals("value = 6743", child.getValue(), "6743");      
+        assertEquals("value = 6743", "6743", child.getValue());      
         
         
     }
@@ -436,25 +444,25 @@
         ComponentBean bean = standardConfigBean.getElement("baseSymbolLabel");
         assertNotNull(bean);
         //look for a base symbol definition
-        String symbol = (String) bean.getSymbols().get("@mystyle");
+        SymbolBean symbol = (SymbolBean) bean.getSymbols().get("@mystyle");
         assertNotNull(symbol);
-        assertEquals("@mystyle == color:blue", symbol, "color:blue");
+        assertEquals("@mystyle == color:blue", "color:blue", 
symbol.getValue());
 
         // symbol1Label extends baseSymbolLabel
         bean = standardConfigBean.getElement("symbol1Label");
         assertNotNull(bean);
         //look for inherited symbol
-        symbol = (String) bean.getSymbols().get("@mystyle");
+        symbol = (SymbolBean) bean.getSymbols().get("@mystyle");
         assertNotNull(symbol);
-        assertEquals("@mystyle == color:blue", symbol, "color:blue");
+        assertEquals("@mystyle == color:blue", "color:blue", 
symbol.getValue());
 
         // symbol2Label extends symbol1Label
         bean = standardConfigBean.getElement("symbol2Label");
         assertNotNull(bean);
         //look for an overridden symbol
-        symbol = (String) bean.getSymbols().get("@mystyle");
+        symbol = (SymbolBean) bean.getSymbols().get("@mystyle");
         assertNotNull(symbol);
-        assertEquals("@mystyle == color:red", symbol, "color:red");
+        assertEquals("@mystyle == color:red", "color:red", symbol.getValue());
 
         
         //test nested/inner element inheritance
@@ -467,14 +475,14 @@
             ElementBean ebean = (ElementBean) ei.next();
             if (ebean.getRenderId() == 1) {
                 //look for inherited symbol
-                symbol = (String) ebean.getSymbols().get("@mystyle");
+                symbol = (SymbolBean) ebean.getSymbols().get("@mystyle");
                 assertNotNull(symbol);
-                assertEquals("@mystyle == color:blue", symbol, "color:blue");  
              
+                assertEquals("@mystyle == color:blue", "color:blue", 
symbol.getValue());                
             } else if (ebean.getRenderId() == 2) {
                 //look for an overridden symbol
-                symbol = (String) ebean.getSymbols().get("@mystyle");
+                symbol = (SymbolBean) ebean.getSymbols().get("@mystyle");
                 assertNotNull(symbol);
-                assertEquals("@mystyle == color:red", symbol, "color:red");
+                assertEquals("@mystyle == color:red", "color:red", 
symbol.getValue());
                 
             }
         }


Reply via email to