struts-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From craig...@apache.org
Subject svn commit: r165369 [1/7] - in /struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay: component/ component/chain/ config/ config/beans/ parser/ parser/builder/ parser/builder/chain/ taglib/ utils/
Date Sat, 30 Apr 2005 01:39:52 GMT
Author: craigmcc
Date: Fri Apr 29 18:39:50 2005
New Revision: 165369

URL: http://svn.apache.org/viewcvs?rev=165369&view=rev
Log:
Apply patch containing Javadoc changes.

PR: Bugzilla #34496
Submitted By: Gary VanMatre <gvanmatre AT comcast.net>

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/component/chain/PropertyActionCommand.java
    struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/component/chain/PropertyActionListenerCommand.java
    struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/component/chain/PropertyValidatorCommand.java
    struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/component/chain/PropertyValueChangeListenerCommand.java
    struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/component/chain/PropertyValueCommand.java
    struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/config/ClayConfigureListener.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/Globals.java
    struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/config/beans/ActionListenerBean.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/config/beans/ConfigBean.java
    struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/config/beans/ConfigBeanFactory.java
    struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/config/beans/ConverterBean.java
    struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/config/beans/ElementBean.java
    struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/config/beans/InnerComponentBean.java
    struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/config/beans/TemplateConfigBean.java
    struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/config/beans/ValidatorBean.java
    struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/config/beans/ValueChangeListenerBean.java
    struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/parser/AttributeTokenizer.java
    struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/parser/Node.java
    struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/parser/NodeTokenizer.java
    struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/parser/Parser.java
    struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/parser/Token.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/BuilderFactory.java
    struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/parser/builder/CommandButtonBuilder.java
    struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/parser/builder/FormBuilder.java
    struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/parser/builder/InputTextBuilder.java
    struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/parser/builder/MorphBuilder.java
    struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/parser/builder/OutputLabelBuilder.java
    struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/parser/builder/SelectBooleanCheckboxBuilder.java
    struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/parser/builder/SelectItemBuilder.java
    struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/parser/builder/SelectItemsBuilder.java
    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
    struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/parser/builder/SelectOneRadioBuilder.java
    struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/parser/builder/VerbatimBuilder.java
    struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/parser/builder/chain/BuilderRuleContext.java
    struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/parser/builder/chain/DefaultBuilderRule.java
    struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/parser/builder/chain/FormBuilderRule.java
    struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/parser/builder/chain/InputBuilderRule.java
    struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/parser/builder/chain/LabelBuilderRule.java
    struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/parser/builder/chain/OptionBuilderRule.java
    struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/parser/builder/chain/SelectBuilderRule.java
    struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/parser/builder/chain/SpanBuilderRule.java
    struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/parser/builder/chain/shale-builder-config.xml
    struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/taglib/ClayTag.java
    struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/utils/PropUtils.java

Modified: struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/component/Clay.java
URL: http://svn.apache.org/viewcvs/struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/component/Clay.java?rev=165369&r1=165368&r2=165369&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 Fri Apr 29 18:39:50 2005
@@ -1,426 +1,426 @@
-/*
- * Copyright 2005 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.component;
-
-import java.io.IOException;
-import java.net.URL;
-import java.util.Iterator;
-
-import javax.faces.component.UIComponent;
-import javax.faces.component.UINamingContainer;
-import javax.faces.context.FacesContext;
-import javax.faces.el.MethodBinding;
-
-import org.apache.commons.chain.Catalog;
-import org.apache.commons.chain.CatalogFactory;
-import org.apache.commons.chain.Command;
-import org.apache.commons.chain.config.ConfigParser;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.shale.clay.component.chain.AbstractCommand;
-import org.apache.shale.clay.component.chain.ClayContext;
-import org.apache.shale.clay.config.Globals;
-import org.apache.shale.clay.config.beans.AttributeBean;
-import org.apache.shale.clay.config.beans.ConfigBean;
-import org.apache.shale.clay.config.beans.ConfigBeanFactory;
-import org.apache.shale.clay.config.beans.ComponentBean;
-import org.apache.shale.util.Messages;
-
-public class Clay extends UINamingContainer {
-    
-    /**
-     * <p>
-     * Commons logger utility class instance
-     * </p>
-     */
-    private static Log log;
-    static {
-        log = LogFactory.getLog(Clay.class);
-    }
-    
-    /**
-     * <p>
-     * Message resources for this class.
-     * </p>
-     */
-    private static Messages messages = new Messages(
-            "org.apache.shale.clay.Bundle", Clay.class.getClassLoader());
-    
-    /**
-     * <p>
-     * Loads the chains config using the resource defined by config file
-     * <code>Globals.CLAY_RESOURCE_NAME</code>. These chain commands are used
-     * to build the clay component subtree from a root {@link ComponentBean}
-     * obtained for a {@link ConfigBean} instance from the
-     * {@link ConfigBeanFactory}.
-     * </p>
-     *
-     * @return {@link Catalog} instance of a catalog defined by catalog
-     *         <code>Globals.CLAY_CATALOG_NAME</code>
-     */
-    protected Catalog getCatalog() throws Exception {
-        
-        // Look up the "shale" catalog, creating one if necessary
-        Catalog catalog = CatalogFactory.getInstance().getCatalog(
-                Globals.CLAY_CATALOG_NAME);
-        if (catalog == null) {
-            
-            ConfigParser parser = new ConfigParser();
-            URL url = this.getClass().getClassLoader().getResource(
-                    Globals.CLAY_RESOURCE_NAME);
-            if (url == null) {
-                throw new IllegalArgumentException(Globals.CLAY_RESOURCE_NAME);
-            }
-            parser.parse(url);
-            
-            catalog = CatalogFactory.getInstance().getCatalog(
-                    Globals.CLAY_CATALOG_NAME);
-            
-        }
-        
-        return catalog;
-        
-    }
-    
-    /**
-     * <p>
-     * Unique identifier that is used to define a simple or complex component.
-     * The suffix of this identifier will be used to determine if the component
-     * metadata will be loaded from a HTML style of document or a XML defining
-     * document
-     * </p>
-     */
-    private String jsfid = null;
-    
-    /**
-     * <p>
-     * The logical name used to access a managed bean. The value will be replace
-     * all occurances of "managed-bean-name" in the binding component attribute
-     * expressions.
-     * </p>
-     */
-    private String managedBeanName = null;
-    
-    /**
-     * <p>
-     * A <code>validator</code> style of method event that is fired when
-     * building the sub component tree using the <code>jsfid</code> as the key
-     * defining the component metadata</code>
-     * </p>
-     */
-    private String shapeValidator = null;
-    
-    /**
-     * <p>
-     * The root of the metadata used to build the component subtree.
-     * </p>
-     */
-    private ComponentBean displayElementRoot = null;
-    
-    /**
-     * <p>
-     * Returns the unique identifier used to build the component subtree
-     * </p>
-     */
-    public String getJsfid() {
-        return jsfid;
-    }
-    
-    /**
-     * <p>
-     * Sets the unique identifier used to build the component subtree
-     * </p>
-     */
-    public void setJsfid(String jsfid) {
-        this.jsfid = jsfid;
-    }
-    
-    /**
-     * <p>
-     * Retuns the <code>validator</code> signature event that is invoked when
-     * the component metadata is retrieved.
-     * </p>
-     */
-    public String getShapeValidator() {
-        return shapeValidator;
-    }
-    
-    /**
-     * <p>
-     * Sets the <code>validator</code> signature event that is invoked when
-     * the component metadata is retrieved.
-     * </p>
-     */
-    public void setShapeValidator(String loadShapeAction) {
-        this.shapeValidator = loadShapeAction;
-    }
-    
-    /**
-     * <p>
-     * Returns the logical bean name that replaces any occurance of
-     * "managed-bean-name" within a binding expression.
-     * </p>
-     */
-    public String getManagedBeanName() {
-        return managedBeanName;
-    }
-    
-    /**
-     * <p>
-     * Sets the logical bean name that replaces any occurance of
-     * "managed-bean-name" within a binding expression.
-     * </p>
-     */
-    public void setManagedBeanName(String mbeanMnemonic) {
-        this.managedBeanName = mbeanMnemonic;
-    }
-    
-    /**
-     * <p>
-     * Retuns the root metadata component that is used to add to the component
-     * tree. It locates the {@link ComponentBean} using the <code>jsfid</code>
-     * attribute as the key. A call to the {@link ConfigBeanFactory} locates the
-     * correct {@link ConfigBean} used to find the {@link ComponentBean}. </b>
-     */
-    protected ComponentBean getRootElement() {
-        
-        ConfigBean config = ConfigBeanFactory.findConfig(getJsfid());
-        
-        if (config == null)
-            throw new NullPointerException(messages
-                    .getMessage("clay.config.notloaded"));
-        
-        // find the top-level display element associated with the subtree
-        ComponentBean b = (ComponentBean) config.getElement(jsfid);
-        if (b == null)
-            throw new NullPointerException(messages.getMessage(
-                    "clay.jsfid.notfound", new Object[] { jsfid }));
-                    
-                    return b;
-    }
-    
-    /**
-     * <p>
-     * This is where the clay component loads the root {@link ComponentBean} by
-     * calling the
-     * <code>getRootElement()<code> method or while invoking the <code>shapeValidator</code> callback event.
-     * The subtree is created using the <code>Globals.ADD_COMPONENT_COMMAND_NAME</code> from the
-     * <code>Globals.CLAY_CATALOG_NAME</code> in the <code>Globals.CLAY_RESOURCE_NAME</code>.
-     */
-    public void encodeBegin(FacesContext context) throws IOException {
-        
-        if (log.isTraceEnabled())
-            log.trace("encodeBegin(FacesContext)");
-        
-        if (getDisplayElementRoot() == null) {
-            if (!getJsfid().equals(Globals.RUNTIME_ELEMENT_ID)) {
-                displayElementRoot = getRootElement();
-            } else {
-                displayElementRoot = new ComponentBean();
-                displayElementRoot
-                        .setComponentType("javax.faces.HtmlOutputText");
-                displayElementRoot.setJsfid(getJsfid());
-                
-            }
-            
-            // this callback will give a hook to override
-            // or alter the root display element by
-            // using the getter and setter for the displayElementRoot
-            if (this.getShapeValidator() != null) {
-                
-                AttributeBean attr = new AttributeBean();
-                attr.setName("validator");
-                attr.setValue(getShapeValidator());
-                attr.setUseMethodLateBinding(Boolean.TRUE.toString());
-                
-                ClayContext clayContext = new ClayContext();
-                clayContext.setAttribute(attr);
-                clayContext.setManagedBeanName(getManagedBeanName());
-                
-                String expr = AbstractCommand.replaceMnemonic(clayContext);
-                Class[] methodSignature = {
-                    javax.faces.context.FacesContext.class,
-                            javax.faces.component.UIComponent.class,
-                            java.lang.Object.class };
-                            
-                            MethodBinding binding = getFacesContext().getApplication()
-                            .createMethodBinding(expr, methodSignature);
-                            
-                            if (log.isDebugEnabled()) {
-                                log
-                                        .debug(messages
-                                        .getMessage("clay.invoke.shapeValidator"));
-                            }
-                            
-                            Object[] args = { context, this, displayElementRoot };
-                            binding.invoke(context, args);
-                            
-            }
-            
-            // Recursively build the subtree and fixup references. The root
-            // of the subview will be assinged to the child private property.
-            
-            ClayContext clayContext = new ClayContext();
-            clayContext.setChild(null);
-            clayContext.setDisplayElement(getDisplayElementRoot());
-            clayContext.setJsfid(getJsfid());
-            clayContext.setFacesContext(getFacesContext());
-            clayContext.setManagedBeanName(getManagedBeanName());
-            clayContext.setRootElement(getDisplayElementRoot());
-            clayContext.setParent(this);
-            
-            Catalog catalog = null;
-            try {
-                catalog = getCatalog();
-            } catch (Exception e) {
-                System.out.println(e);
-            }
-            Command command = catalog
-                    .getCommand(Globals.ADD_COMPONENT_COMMAND_NAME);
-            
-            try {
-                command.execute(clayContext);
-            } catch (Exception e) {
-                log.error(e);
-                throw new RuntimeException(e);
-            }
-            
-        }
-        
-        super.encodeBegin(context);
-    }
-    
-    /**
-     * <p>
-     * Recursively invokes the rendering of the sub component tree.
-     * </p>
-     */
-    protected void recursiveRenderChildren(UIComponent child,
-            FacesContext context) throws IOException {
-        
-        if (!child.getRendersChildren()) {
-            Iterator ci = child.getChildren().iterator();
-            while (ci.hasNext()) {
-                UIComponent c = (UIComponent) ci.next();
-                c.encodeBegin(context);
-                
-                if (!c.getRendersChildren())
-                    recursiveRenderChildren(c, context);
-                else
-                    c.encodeChildren(context);
-                
-                c.encodeEnd(context);
-                c = null;
-            }
-        } else {
-            // let the component handle iterating over the children
-            child.encodeChildren(context);
-        }
-    }
-    
-    /**
-     * <p>
-     * Calls to super and adds some trace logging
-     * </p>
-     */
-    public void encodeChildren(FacesContext context) throws IOException {
-        super.encodeChildren(context);
-        
-        if (log.isTraceEnabled())
-            log.trace("encodeChildren(FacesContext)");
-        
-    }
-    
-    /**
-     * <p>
-     * Calls to super and invokes the rendering of the sub component tree if the
-     * parent component doesn't render it's children.
-     * </p>
-     */
-    public void encodeEnd(FacesContext context) throws IOException {
-        
-        if (log.isTraceEnabled())
-            log.trace("encodeEnd(FacesContext)");
-        
-        // if the parents, parent handles the renderering, like a pannelGrid, it
-        // will take care of the rendering of the root subview node.
-        if (!getParent().getRendersChildren()) {
-            recursiveRenderChildren(this, context);
-        }
-    }
-    
-    /**
-     * <p>
-     * Retuns the root {@link ComponentBean} used to build the clay subtree
-     * component
-     * </p>
-     */
-    public ComponentBean getDisplayElementRoot() {
-        return displayElementRoot;
-    }
-    
-    /**
-     * <p>
-     * Sets the root {@link ComponentBean} used to build the clay subtree
-     * component
-     * </p>
-     */
-    public void setDisplayElementRoot(ComponentBean displayElementRoot) {
-        this.displayElementRoot = displayElementRoot;
-    }
-    
-    /**
-     * <p>
-     * Restores a components state
-     * </p>
-     *
-     * @see javax.faces.component.StateHolder#restoreState(javax.faces.context.FacesContext,
-     *      java.lang.Object)
-     */
-    public void restoreState(FacesContext context, Object obj) {
-        
-        Object[] aobj = (Object[]) obj;
-        super.restoreState(context, aobj[0]);
-        
-        jsfid = ((String) aobj[1]);
-        managedBeanName = ((String) aobj[2]);
-        shapeValidator = ((String) aobj[3]);
-        displayElementRoot = ((ComponentBean) aobj[4]);
-        
-    }
-    
-    /**
-     * <p>
-     * Saves a component's state
-     * </p>
-     *
-     * @see javax.faces.component.StateHolder#saveState(javax.faces.context.FacesContext)
-     */
-    public Object saveState(FacesContext context) {
-        Object[] aobj = new Object[5];
-        aobj[0] = super.saveState(context);
-        aobj[1] = jsfid;
-        aobj[2] = managedBeanName;
-        aobj[3] = shapeValidator;
-        aobj[4] = displayElementRoot;
-        
-        return aobj;
-    }
-    
-}
+/*
+ * Copyright 2005 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.component;
+
+import java.io.IOException;
+import java.net.URL;
+import java.util.Iterator;
+
+import javax.faces.component.UIComponent;
+import javax.faces.component.UINamingContainer;
+import javax.faces.context.FacesContext;
+import javax.faces.el.MethodBinding;
+
+import org.apache.commons.chain.Catalog;
+import org.apache.commons.chain.CatalogFactory;
+import org.apache.commons.chain.Command;
+import org.apache.commons.chain.config.ConfigParser;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.shale.clay.component.chain.AbstractCommand;
+import org.apache.shale.clay.component.chain.ClayContext;
+import org.apache.shale.clay.config.Globals;
+import org.apache.shale.clay.config.beans.AttributeBean;
+import org.apache.shale.clay.config.beans.ConfigBean;
+import org.apache.shale.clay.config.beans.ConfigBeanFactory;
+import org.apache.shale.clay.config.beans.ComponentBean;
+import org.apache.shale.util.Messages;
+
+public class Clay extends UINamingContainer {
+    
+    /**
+     * <p>
+     * Commons logger utility class instance
+     * </p>
+     */
+    private static Log log;
+    static {
+        log = LogFactory.getLog(Clay.class);
+    }
+    
+    /**
+     * <p>
+     * Message resources for this class.
+     * </p>
+     */
+    private static Messages messages = new Messages(
+            "org.apache.shale.clay.Bundle", Clay.class.getClassLoader());
+    
+    /**
+     * <p>
+     * Loads the chains config using the resource defined by config file
+     * <code>Globals.CLAY_RESOURCE_NAME</code>. These chain commands are used
+     * to build the clay component subtree from a root {@link ComponentBean}
+     * obtained for a {@link ConfigBean} instance from the
+     * {@link ConfigBeanFactory}.
+     * </p>
+     *
+     * @return {@link Catalog} instance of a catalog defined by catalog
+     *         <code>Globals.CLAY_CATALOG_NAME</code>
+     */
+    protected Catalog getCatalog() throws Exception {
+        
+        // Look up the "shale" catalog, creating one if necessary
+        Catalog catalog = CatalogFactory.getInstance().getCatalog(
+                Globals.CLAY_CATALOG_NAME);
+        if (catalog == null) {
+            
+            ConfigParser parser = new ConfigParser();
+            URL url = this.getClass().getClassLoader().getResource(
+                    Globals.CLAY_RESOURCE_NAME);
+            if (url == null) {
+                throw new IllegalArgumentException(Globals.CLAY_RESOURCE_NAME);
+            }
+            parser.parse(url);
+            
+            catalog = CatalogFactory.getInstance().getCatalog(
+                    Globals.CLAY_CATALOG_NAME);
+            
+        }
+        
+        return catalog;
+        
+    }
+    
+    /**
+     * <p>
+     * Unique identifier that is used to define a simple or complex component.
+     * The suffix of this identifier will be used to determine if the component
+     * metadata will be loaded from a HTML style of document or a XML defining
+     * document
+     * </p>
+     */
+    private String jsfid = null;
+    
+    /**
+     * <p>
+     * The logical name used to access a managed bean. The value will be replace
+     * all occurrences of "managed-bean-name" in the binding component attribute
+     * expressions.
+     * </p>
+     */
+    private String managedBeanName = null;
+    
+    /**
+     * <p>
+     * A <code>validator</code> style of method event that is fired when
+     * building the sub component tree using the <code>jsfid</code> as the key
+     * defining the component metadata</code>
+     * </p>
+     */
+    private String shapeValidator = null;
+    
+    /**
+     * <p>
+     * The root of the metadata used to build the component subtree.
+     * </p>
+     */
+    private ComponentBean displayElementRoot = null;
+    
+    /**
+     * <p>
+     * Returns the unique identifier used to build the component subtree
+     * </p>
+     */
+    public String getJsfid() {
+        return jsfid;
+    }
+    
+    /**
+     * <p>
+     * Sets the unique identifier used to build the component subtree
+     * </p>
+     */
+    public void setJsfid(String jsfid) {
+        this.jsfid = jsfid;
+    }
+    
+    /**
+     * <p>
+     * Retuns the <code>validator</code> signature event that is invoked when
+     * the component metadata is retrieved.
+     * </p>
+     */
+    public String getShapeValidator() {
+        return shapeValidator;
+    }
+    
+    /**
+     * <p>
+     * Sets the <code>validator</code> signature event that is invoked when
+     * the component metadata is retrieved.
+     * </p>
+     */
+    public void setShapeValidator(String loadShapeAction) {
+        this.shapeValidator = loadShapeAction;
+    }
+    
+    /**
+     * <p>
+     * Returns the logical bean name that replaces any occurance of
+     * "managed-bean-name" within a binding expression.
+     * </p>
+     */
+    public String getManagedBeanName() {
+        return managedBeanName;
+    }
+    
+    /**
+     * <p>
+     * Sets the logical bean name that replaces any occurance of
+     * "managed-bean-name" within a binding expression.
+     * </p>
+     */
+    public void setManagedBeanName(String mbeanMnemonic) {
+        this.managedBeanName = mbeanMnemonic;
+    }
+    
+    /**
+     * <p>
+     * Returns the root metadata component that is used to add to the component
+     * tree. It locates the {@link ComponentBean} using the <code>jsfid</code>
+     * attribute as the key. A call to the {@link ConfigBeanFactory} locates the
+     * correct {@link ConfigBean} used to find the {@link ComponentBean}. </b>
+     */
+    protected ComponentBean getRootElement() {
+        
+        ConfigBean config = ConfigBeanFactory.findConfig(getJsfid());
+        
+        if (config == null)
+            throw new NullPointerException(messages
+                    .getMessage("clay.config.notloaded"));
+        
+        // find the top-level display element associated with the subtree
+        ComponentBean b = (ComponentBean) config.getElement(jsfid);
+        if (b == null)
+            throw new NullPointerException(messages.getMessage(
+                    "clay.jsfid.notfound", new Object[] { jsfid }));
+                    
+                    return b;
+    }
+    
+    /**
+     * <p>
+     * This is where the clay component loads the root {@link ComponentBean} by
+     * calling the
+     * <code>getRootElement()<code> method or while invoking the <code>shapeValidator</code> callback event.
+     * The subtree is created using the <code>Globals.ADD_COMPONENT_COMMAND_NAME</code> from the
+     * <code>Globals.CLAY_CATALOG_NAME</code> in the <code>Globals.CLAY_RESOURCE_NAME</code>.
+     */
+    public void encodeBegin(FacesContext context) throws IOException {
+        
+        if (log.isTraceEnabled())
+            log.trace("encodeBegin(FacesContext)");
+        
+        if (getDisplayElementRoot() == null) {
+            if (!getJsfid().equals(Globals.RUNTIME_ELEMENT_ID)) {
+                displayElementRoot = getRootElement();
+            } else {
+                displayElementRoot = new ComponentBean();
+                displayElementRoot
+                        .setComponentType("javax.faces.HtmlOutputText");
+                displayElementRoot.setJsfid(getJsfid());
+                
+            }
+            
+            // this callback will give a hook to override
+            // or alter the root display element by
+            // using the getter and setter for the displayElementRoot
+            if (this.getShapeValidator() != null) {
+                
+                AttributeBean attr = new AttributeBean();
+                attr.setName("validator");
+                attr.setValue(getShapeValidator());
+                attr.setUseMethodLateBinding(Boolean.TRUE.toString());
+                
+                ClayContext clayContext = new ClayContext();
+                clayContext.setAttribute(attr);
+                clayContext.setManagedBeanName(getManagedBeanName());
+                
+                String expr = AbstractCommand.replaceMnemonic(clayContext);
+                Class[] methodSignature = {
+                    javax.faces.context.FacesContext.class,
+                            javax.faces.component.UIComponent.class,
+                            java.lang.Object.class };
+                            
+                            MethodBinding binding = getFacesContext().getApplication()
+                            .createMethodBinding(expr, methodSignature);
+                            
+                            if (log.isDebugEnabled()) {
+                                log
+                                        .debug(messages
+                                        .getMessage("clay.invoke.shapeValidator"));
+                            }
+                            
+                            Object[] args = { context, this, displayElementRoot };
+                            binding.invoke(context, args);
+                            
+            }
+            
+            // Recursively build the subtree and fixup references. The root
+            // of the subview will be assinged to the child private property.
+            
+            ClayContext clayContext = new ClayContext();
+            clayContext.setChild(null);
+            clayContext.setDisplayElement(getDisplayElementRoot());
+            clayContext.setJsfid(getJsfid());
+            clayContext.setFacesContext(getFacesContext());
+            clayContext.setManagedBeanName(getManagedBeanName());
+            clayContext.setRootElement(getDisplayElementRoot());
+            clayContext.setParent(this);
+            
+            Catalog catalog = null;
+            try {
+                catalog = getCatalog();
+            } catch (Exception e) {
+                System.out.println(e);
+            }
+            Command command = catalog
+                    .getCommand(Globals.ADD_COMPONENT_COMMAND_NAME);
+            
+            try {
+                command.execute(clayContext);
+            } catch (Exception e) {
+                log.error(e);
+                throw new RuntimeException(e);
+            }
+            
+        }
+        
+        super.encodeBegin(context);
+    }
+    
+    /**
+     * <p>
+     * Recursively invokes the rendering of the sub component tree.
+     * </p>
+     */
+    protected void recursiveRenderChildren(UIComponent child,
+            FacesContext context) throws IOException {
+        
+        if (!child.getRendersChildren()) {
+            Iterator ci = child.getChildren().iterator();
+            while (ci.hasNext()) {
+                UIComponent c = (UIComponent) ci.next();
+                c.encodeBegin(context);
+                
+                if (!c.getRendersChildren())
+                    recursiveRenderChildren(c, context);
+                else
+                    c.encodeChildren(context);
+                
+                c.encodeEnd(context);
+                c = null;
+            }
+        } else {
+            // let the component handle iterating over the children
+            child.encodeChildren(context);
+        }
+    }
+    
+    /**
+     * <p>
+     * Calls to super and adds some trace logging
+     * </p>
+     */
+    public void encodeChildren(FacesContext context) throws IOException {
+        super.encodeChildren(context);
+        
+        if (log.isTraceEnabled())
+            log.trace("encodeChildren(FacesContext)");
+        
+    }
+    
+    /**
+     * <p>
+     * Calls to super and invokes the rendering of the sub component tree if the
+     * parent component doesn't render it's children.
+     * </p>
+     */
+    public void encodeEnd(FacesContext context) throws IOException {
+        
+        if (log.isTraceEnabled())
+            log.trace("encodeEnd(FacesContext)");
+        
+        // if the parents, parent handles the renderering, like a pannelGrid, it
+        // will take care of the rendering of the root subview node.
+        if (!getParent().getRendersChildren()) {
+            recursiveRenderChildren(this, context);
+        }
+    }
+    
+    /**
+     * <p>
+     * Retuns the root {@link ComponentBean} used to build the clay subtree
+     * component
+     * </p>
+     */
+    public ComponentBean getDisplayElementRoot() {
+        return displayElementRoot;
+    }
+    
+    /**
+     * <p>
+     * Sets the root {@link ComponentBean} used to build the clay subtree
+     * component
+     * </p>
+     */
+    public void setDisplayElementRoot(ComponentBean displayElementRoot) {
+        this.displayElementRoot = displayElementRoot;
+    }
+    
+    /**
+     * <p>
+     * Restores a components state
+     * </p>
+     *
+     * @see javax.faces.component.StateHolder#restoreState(javax.faces.context.FacesContext,
+     *      java.lang.Object)
+     */
+    public void restoreState(FacesContext context, Object obj) {
+        
+        Object[] aobj = (Object[]) obj;
+        super.restoreState(context, aobj[0]);
+        
+        jsfid = ((String) aobj[1]);
+        managedBeanName = ((String) aobj[2]);
+        shapeValidator = ((String) aobj[3]);
+        displayElementRoot = ((ComponentBean) aobj[4]);
+        
+    }
+    
+    /**
+     * <p>
+     * Saves a component's state
+     * </p>
+     *
+     * @see javax.faces.component.StateHolder#saveState(javax.faces.context.FacesContext)
+     */
+    public Object saveState(FacesContext context) {
+        Object[] aobj = new Object[5];
+        aobj[0] = super.saveState(context);
+        aobj[1] = jsfid;
+        aobj[2] = managedBeanName;
+        aobj[3] = shapeValidator;
+        aobj[4] = displayElementRoot;
+        
+        return aobj;
+    }
+    
+}

Modified: struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/component/chain/AbstractCommand.java
URL: http://svn.apache.org/viewcvs/struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/component/chain/AbstractCommand.java?rev=165369&r1=165368&r2=165369&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 Fri Apr 29 18:39:50 2005
@@ -1,113 +1,113 @@
-/*
- * Copyright 2005 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.component.chain;
-
-import java.net.URL;
-
-import org.apache.commons.chain.Catalog;
-import org.apache.commons.chain.CatalogFactory;
-import org.apache.commons.chain.Command;
-import org.apache.commons.chain.Context;
-import org.apache.commons.chain.config.ConfigParser;
-import org.apache.shale.clay.component.Clay;
-import org.apache.shale.clay.config.Globals;
-import org.apache.shale.util.Messages;
-
-/**
- * <p>
- * The base class for the command's that create the component tree
- * </p>
- */
-public abstract class AbstractCommand implements Command {
-    
-    /**
-     * <p>
-     * Message resources for this class.
-     * </p>
-     */
-    protected static Messages messages = new Messages(
-            "org.apache.shale.clay.Bundle", AbstractCommand.class
-            .getClassLoader());
-    
-    /**
-     * <p>
-     * Returns the {@link Catalog} from the
-     * <code>Globals.CLAY_CATALOG_NAME</code> in the
-     * <code>Globals.CLAY_RESOURCE_NAME</code> config file.
-     * </p>
-     */
-    protected Catalog getCatalog() throws Exception {
-        
-        Catalog catalog = CatalogFactory.getInstance().getCatalog(
-                Globals.CLAY_CATALOG_NAME);
-        if (catalog == null) {
-            
-            ConfigParser parser = new ConfigParser();
-            URL url = this.getClass().getClassLoader().getResource(
-                    Globals.CLAY_RESOURCE_NAME);
-            if (url == null) {
-                throw new IllegalArgumentException(Globals.CLAY_RESOURCE_NAME);
-            }
-            parser.parse(url);
-            
-            catalog = CatalogFactory.getInstance().getCatalog(
-                    Globals.CLAY_CATALOG_NAME);
-            
-        }
-        
-        return catalog;
-        
-    }
-    
-    /**
-     * <p>
-     * This call is used to substitue an attribute binding expression containing
-     * the literal string <strong>managed-bean-name</strong> with the
-     * <code>managedBeanName</code> property value in the {@link ClayContext}.
-     * </p>
-     */
-    public static String replaceMnemonic(ClayContext context) {
-        
-        StringBuffer buff = new StringBuffer(context.getAttribute().getValue());
-        
-        for (int i = 0; i < (buff.length() - Globals.MANAGED_BEAN_MNEMONIC
-                .length()); i++) {
-            String token = buff.substring(i, i
-                    + Globals.MANAGED_BEAN_MNEMONIC.length());
-            if (token.compareToIgnoreCase(Globals.MANAGED_BEAN_MNEMONIC) == 0) {
-                buff.delete(i, i + Globals.MANAGED_BEAN_MNEMONIC.length());
-                buff.insert(i, context.getManagedBeanName());
-            }
-            
-            token = null;
-        }
-        
-        return buff.toString();
-        
-    }
-    
-    /**
-     * <p>
-     * This method comes from the <code>Command</code> interfaces. This method is
-     * invoked while executing the <code>Chain</code>.
-     * </p>
-     */
-    public abstract boolean execute(Context arg0) throws Exception;
-    
-}
+/*
+ * Copyright 2005 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.component.chain;
+
+import java.net.URL;
+
+import org.apache.commons.chain.Catalog;
+import org.apache.commons.chain.CatalogFactory;
+import org.apache.commons.chain.Command;
+import org.apache.commons.chain.Context;
+import org.apache.commons.chain.config.ConfigParser;
+import org.apache.shale.clay.component.Clay;
+import org.apache.shale.clay.config.Globals;
+import org.apache.shale.util.Messages;
+
+/**
+ * <p>
+ * The base class for the command's that create the component tree
+ * </p>
+ */
+public abstract class AbstractCommand implements Command {
+    
+    /**
+     * <p>
+     * Message resources for this class.
+     * </p>
+     */
+    protected static Messages messages = new Messages(
+            "org.apache.shale.clay.Bundle", AbstractCommand.class
+            .getClassLoader());
+    
+    /**
+     * <p>
+     * Returns the {@link Catalog} from the
+     * <code>Globals.CLAY_CATALOG_NAME</code> in the
+     * <code>Globals.CLAY_RESOURCE_NAME</code> configuration file.
+     * </p>
+     */
+    protected Catalog getCatalog() throws Exception {
+        
+        Catalog catalog = CatalogFactory.getInstance().getCatalog(
+                Globals.CLAY_CATALOG_NAME);
+        if (catalog == null) {
+            
+            ConfigParser parser = new ConfigParser();
+            URL url = this.getClass().getClassLoader().getResource(
+                    Globals.CLAY_RESOURCE_NAME);
+            if (url == null) {
+                throw new IllegalArgumentException(Globals.CLAY_RESOURCE_NAME);
+            }
+            parser.parse(url);
+            
+            catalog = CatalogFactory.getInstance().getCatalog(
+                    Globals.CLAY_CATALOG_NAME);
+            
+        }
+        
+        return catalog;
+        
+    }
+    
+    /**
+     * <p>
+     * This call is used to substitue an attribute binding expression containing
+     * the literal string <strong>managed-bean-name</strong> with the
+     * <code>managedBeanName</code> property value in the {@link ClayContext}.
+     * </p>
+     */
+    public static String replaceMnemonic(ClayContext context) {
+        
+        StringBuffer buff = new StringBuffer(context.getAttribute().getValue());
+        
+        for (int i = 0; i < (buff.length() - Globals.MANAGED_BEAN_MNEMONIC
+                .length()); i++) {
+            String token = buff.substring(i, i
+                    + Globals.MANAGED_BEAN_MNEMONIC.length());
+            if (token.compareToIgnoreCase(Globals.MANAGED_BEAN_MNEMONIC) == 0) {
+                buff.delete(i, i + Globals.MANAGED_BEAN_MNEMONIC.length());
+                buff.insert(i, context.getManagedBeanName());
+            }
+            
+            token = null;
+        }
+        
+        return buff.toString();
+        
+    }
+    
+    /**
+     * <p>
+     * This method comes from the <code>Command</code> interfaces. This method is
+     * invoked while executing the <code>Chain</code>.
+     * </p>
+     */
+    public abstract boolean execute(Context arg0) throws Exception;
+    
+}

Modified: struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/component/chain/PropertyActionCommand.java
URL: http://svn.apache.org/viewcvs/struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/component/chain/PropertyActionCommand.java?rev=165369&r1=165368&r2=165369&view=diff
==============================================================================
--- struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/component/chain/PropertyActionCommand.java (original)
+++ struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/component/chain/PropertyActionCommand.java Fri Apr 29 18:39:50 2005
@@ -1,77 +1,100 @@
-/*
- * Copyright 2005 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.component.chain;
-
-import javax.faces.component.ActionSource;
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-import javax.faces.el.MethodBinding;
-
-import org.apache.commons.chain.Command;
-import org.apache.commons.chain.Context;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.shale.clay.config.beans.AttributeBean;
-import org.apache.shale.clay.config.beans.ComponentBean;
-
-public class PropertyActionCommand extends AbstractCommand implements Command {
-    
-    private static Log log;
-    static {
-        log = LogFactory.getLog(PropertyActionCommand.class);
-    }
-    
-    public boolean execute(Context context) throws Exception {
-        
-        boolean isFinal = false;
-        
-        ClayContext clayContext = (ClayContext) context;
-        if (clayContext == null)
-            throw new NullPointerException(messages.getMessage("clay.null.clayContext"));
-        AttributeBean attributeBean = clayContext.getAttribute();
-        if (attributeBean == null)
-            throw new NullPointerException(messages.getMessage("clay.null.attributeBean"));
-        ComponentBean displayElement = clayContext.getDisplayElement();
-        if (displayElement == null)
-            throw new NullPointerException(messages.getMessage("clay.null.componentBean"));
-        FacesContext facesContext = clayContext.getFacesContext();
-        if (facesContext == null)
-            throw new NullPointerException(messages.getMessage("clay.null.facesContext"));
-        if (attributeBean.getName().equals("action")) {
-            isFinal = true;
-            
-            UIComponent child = (UIComponent) clayContext.getChild();
-            if (child == null)
-                throw new NullPointerException(messages.getMessage("clay.null.childComponent"));
-            
-            if (child instanceof ActionSource) {
-                
-                String expr = replaceMnemonic(clayContext);
-                MethodBinding binding = facesContext.getApplication()
-                .createMethodBinding(expr, null);
-                
-                ((ActionSource) child).setAction((MethodBinding) binding);
-            } else {
-                log.error(messages.getMessage("property.action.error", new Object[] {attributeBean}));
-            }
-        }
-        
-        return isFinal;
-    }
-}
+/*
+ * Copyright 2005 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.component.chain;
+
+import javax.faces.component.ActionSource;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.el.MethodBinding;
+
+import org.apache.commons.chain.Command;
+import org.apache.commons.chain.Context;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.shale.clay.config.beans.AttributeBean;
+import org.apache.shale.clay.config.beans.ComponentBean;
+
+/**
+ * <p>
+ * This <code>Command</code> will create an <code>action</code> method
+ * binding and assign it to the <code>UIComponent</code> implementing the
+ * <code>ActionSource</code> interface.
+ * </p>
+ */
+
+public class PropertyActionCommand extends AbstractCommand implements Command {
+ 
+    /**
+     * <p>
+     * Common logger utility class
+     * </p>
+     */    
+    private static Log log;
+    static {
+        log = LogFactory.getLog(PropertyActionCommand.class);
+    }
+ 
+    /**
+     * <p>
+     * Looks to see if the {@link AttributeBean} on the {@link ClayContext} is a
+     * <code>action</code> attribute. If it is, create a
+     * <code>MethodBinding</code> and assign it to the component returning a
+     * <code>true</code> value. Otherwise, return a <code>false</code>
+     * value. This <code>Command</code> is invoked from the
+     * {@link AssignPropertiesCommand} chain.
+     * </p>
+     */
+    public boolean execute(Context context) throws Exception {
+        
+        boolean isFinal = false;
+        
+        ClayContext clayContext = (ClayContext) context;
+        if (clayContext == null)
+            throw new NullPointerException(messages.getMessage("clay.null.clayContext"));
+        AttributeBean attributeBean = clayContext.getAttribute();
+        if (attributeBean == null)
+            throw new NullPointerException(messages.getMessage("clay.null.attributeBean"));
+        ComponentBean displayElement = clayContext.getDisplayElement();
+        if (displayElement == null)
+            throw new NullPointerException(messages.getMessage("clay.null.componentBean"));
+        FacesContext facesContext = clayContext.getFacesContext();
+        if (facesContext == null)
+            throw new NullPointerException(messages.getMessage("clay.null.facesContext"));
+        if (attributeBean.getName().equals("action")) {
+            isFinal = true;
+            
+            UIComponent child = (UIComponent) clayContext.getChild();
+            if (child == null)
+                throw new NullPointerException(messages.getMessage("clay.null.childComponent"));
+            
+            if (child instanceof ActionSource) {
+                
+                String expr = replaceMnemonic(clayContext);
+                MethodBinding binding = facesContext.getApplication()
+                .createMethodBinding(expr, null);
+                
+                ((ActionSource) child).setAction((MethodBinding) binding);
+            } else {
+                log.error(messages.getMessage("property.action.error", new Object[] {attributeBean}));
+            }
+        }
+        
+        return isFinal;
+    }
+}

Modified: struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/component/chain/PropertyActionListenerCommand.java
URL: http://svn.apache.org/viewcvs/struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/component/chain/PropertyActionListenerCommand.java?rev=165369&r1=165368&r2=165369&view=diff
==============================================================================
--- struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/component/chain/PropertyActionListenerCommand.java (original)
+++ struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/component/chain/PropertyActionListenerCommand.java Fri Apr 29 18:39:50 2005
@@ -1,82 +1,104 @@
-/*
- * Copyright 2005 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.component.chain;
-
-import javax.faces.component.ActionSource;
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-import javax.faces.el.MethodBinding;
-
-import org.apache.commons.chain.Command;
-import org.apache.commons.chain.Context;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.shale.clay.config.beans.AttributeBean;
-import org.apache.shale.clay.config.beans.ComponentBean;
-
-public class PropertyActionListenerCommand extends AbstractCommand implements
-        Command {
-    
-    private static Log log;
-    static {
-        log = LogFactory.getLog(PropertyActionListenerCommand.class);
-    }
-    
-    public boolean execute(Context context) throws Exception {
-        
-        boolean isFinal = false;
-        
-        ClayContext clayContext = (ClayContext) context;
-        if (clayContext == null)
-            throw new NullPointerException(messages.getMessage("clay.null.clayContext"));
-        AttributeBean attributeBean = clayContext.getAttribute();
-        if (attributeBean == null)
-            throw new NullPointerException(messages.getMessage("clay.null.attributeBean"));
-        ComponentBean displayElement = clayContext.getDisplayElement();
-        if (displayElement == null)
-            throw new NullPointerException(messages.getMessage("clay.null.componentBean"));
-        FacesContext facesContext = clayContext.getFacesContext();
-        if (facesContext == null)
-            throw new NullPointerException(messages.getMessage("clay.null.facesContext"));
-        
-        if (attributeBean.getName().equals("actionListener")) {
-            isFinal = true;
-            
-            UIComponent child = (UIComponent) clayContext.getChild();
-            if (child == null)
-                throw new NullPointerException(messages.getMessage("clay.null.childComponent"));
-            
-            if (child instanceof ActionSource) {
-                
-                String expr = replaceMnemonic(clayContext);
-                Class[] methodSignature = { javax.faces.event.ActionEvent.class };
-                
-                MethodBinding binding = facesContext.getApplication()
-                .createMethodBinding(expr, methodSignature);
-                
-                ((ActionSource) child)
-                .setActionListener((MethodBinding) binding);
-            } else {
-                log.error(messages.getMessage("property.actionListener.error", new Object[] {attributeBean}));
-            }
-        }
-        
-        return isFinal;
-    }
-}
+/*
+ * Copyright 2005 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.component.chain;
+
+import javax.faces.component.ActionSource;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.el.MethodBinding;
+
+import org.apache.commons.chain.Command;
+import org.apache.commons.chain.Context;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.shale.clay.config.beans.AttributeBean;
+import org.apache.shale.clay.config.beans.ComponentBean;
+
+/**
+ * <p>
+ * This <code>Command</code> will create an <code>actionListener</code>
+ * method binding and assign it to the <code>UIComponent</code> implementing
+ * the <code>ActionSource</code> interface.
+ * </p>
+ */
+public class PropertyActionListenerCommand extends AbstractCommand implements
+        Command {
+
+    /**
+     * <p>
+     * Common logger utility class
+     * </p>
+     */
+    private static Log log;
+    static {
+        log = LogFactory.getLog(PropertyActionListenerCommand.class);
+    }
+ 
+    /**
+     * <p>
+     * Looks to see if the {@link AttributeBean} on the {@link ClayContext} is a
+     * <code>actionListener</code> attribute. If it is, create a
+     * <code>MethodBinding</code> and assign it to the component returning a
+     * <code>true</code> value. Otherwise, return a <code>false</code>
+     * value. This <code>Command</code> is invoked from the
+     * {@link AssignPropertiesCommand} chain.
+     * </p>
+     */    
+    public boolean execute(Context context) throws Exception {
+        
+        boolean isFinal = false;
+        
+        ClayContext clayContext = (ClayContext) context;
+        if (clayContext == null)
+            throw new NullPointerException(messages.getMessage("clay.null.clayContext"));
+        AttributeBean attributeBean = clayContext.getAttribute();
+        if (attributeBean == null)
+            throw new NullPointerException(messages.getMessage("clay.null.attributeBean"));
+        ComponentBean displayElement = clayContext.getDisplayElement();
+        if (displayElement == null)
+            throw new NullPointerException(messages.getMessage("clay.null.componentBean"));
+        FacesContext facesContext = clayContext.getFacesContext();
+        if (facesContext == null)
+            throw new NullPointerException(messages.getMessage("clay.null.facesContext"));
+        
+        if (attributeBean.getName().equals("actionListener")) {
+            isFinal = true;
+            
+            UIComponent child = (UIComponent) clayContext.getChild();
+            if (child == null)
+                throw new NullPointerException(messages.getMessage("clay.null.childComponent"));
+            
+            if (child instanceof ActionSource) {
+                
+                String expr = replaceMnemonic(clayContext);
+                Class[] methodSignature = { javax.faces.event.ActionEvent.class };
+                
+                MethodBinding binding = facesContext.getApplication()
+                .createMethodBinding(expr, methodSignature);
+                
+                ((ActionSource) child)
+                .setActionListener((MethodBinding) binding);
+            } else {
+                log.error(messages.getMessage("property.actionListener.error", new Object[] {attributeBean}));
+            }
+        }
+        
+        return isFinal;
+    }
+}

Modified: struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/component/chain/PropertyValidatorCommand.java
URL: http://svn.apache.org/viewcvs/struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/component/chain/PropertyValidatorCommand.java?rev=165369&r1=165368&r2=165369&view=diff
==============================================================================
--- struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/component/chain/PropertyValidatorCommand.java (original)
+++ struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/component/chain/PropertyValidatorCommand.java Fri Apr 29 18:39:50 2005
@@ -1,84 +1,106 @@
-/*
- * Copyright 2005 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.component.chain;
-
-import javax.faces.component.EditableValueHolder;
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-import javax.faces.el.MethodBinding;
-
-import org.apache.commons.chain.Command;
-import org.apache.commons.chain.Context;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.shale.clay.config.beans.AttributeBean;
-import org.apache.shale.clay.config.beans.ComponentBean;
-
-public class PropertyValidatorCommand extends AbstractCommand implements
-        Command {
-    
-    private static Log log;
-    static {
-        log = LogFactory.getLog(PropertyValidatorCommand.class);
-    }
-    
-    public boolean execute(Context context) throws Exception {
-        
-        boolean isFinal = false;
-        
-        ClayContext clayContext = (ClayContext) context;
-        if (clayContext == null)
-            throw new NullPointerException(messages.getMessage("clay.null.clayContext"));
-        AttributeBean attributeBean = clayContext.getAttribute();
-        if (attributeBean == null)
-            throw new NullPointerException(messages.getMessage("clay.null.attributeBean"));
-        ComponentBean displayElement = clayContext.getDisplayElement();
-        if (displayElement == null)
-            throw new NullPointerException(messages.getMessage("clay.null.componentBean"));
-        FacesContext facesContext = clayContext.getFacesContext();
-        if (facesContext == null)
-            throw new NullPointerException(messages.getMessage("clay.null.facesContext"));
-        if (attributeBean.getName().equals("validator")) {
-            isFinal = true;
-            
-            UIComponent child = (UIComponent) clayContext.getChild();
-            if (child == null)
-                throw new NullPointerException("child");
-            
-            if (child instanceof EditableValueHolder) {
-                
-                String expr = replaceMnemonic(clayContext);
-                Class[] methodSignature = {
-                    javax.faces.context.FacesContext.class,
-                            javax.faces.component.UIComponent.class,
-                            java.lang.Object.class };
-                            
-                            MethodBinding binding = facesContext.getApplication()
-                            .createMethodBinding(expr, methodSignature);
-                            
-                            ((EditableValueHolder) child)
-                            .setValidator((MethodBinding) binding);
-            } else {
-                log.error(messages.getMessage("property.validator.error", new Object[] {attributeBean}));
-            }
-        }
-        
-        return isFinal;
-    }
-}
+/*
+ * Copyright 2005 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.component.chain;
+
+import javax.faces.component.EditableValueHolder;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.el.MethodBinding;
+
+import org.apache.commons.chain.Command;
+import org.apache.commons.chain.Context;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.shale.clay.config.beans.AttributeBean;
+import org.apache.shale.clay.config.beans.ComponentBean;
+
+/**
+ * <p>
+ * This <code>Command</code> will create an <code>validator</code> method
+ * binding and assign it to the <code>UIComponent</code> implementing the
+ * <code>EditableValueHolder</code> interface. This <code>Command</code> is
+ * invoked from the {@link AssignPropertiesCommand} chain.
+ * </p>
+ */
+public class PropertyValidatorCommand extends AbstractCommand implements
+        Command {
+
+    /**
+     * <p>
+     * Common logger utility class
+     * </p>
+     */
+    private static Log log;
+    static {
+        log = LogFactory.getLog(PropertyValidatorCommand.class);
+    }
+
+    /**
+     * <p>
+     * Looks to see if the {@link AttributeBean} on the {@link ClayContext} is a
+     * <code>validator</code> attribute. If it is, create a
+     * <code>MethodBinding</code> and assign it to the component returning a
+     * <code>true</code> value. Otherwise, return a <code>false</code>
+     * value.
+     * </p>
+     */
+    public boolean execute(Context context) throws Exception {
+        
+        boolean isFinal = false;
+        
+        ClayContext clayContext = (ClayContext) context;
+        if (clayContext == null)
+            throw new NullPointerException(messages.getMessage("clay.null.clayContext"));
+        AttributeBean attributeBean = clayContext.getAttribute();
+        if (attributeBean == null)
+            throw new NullPointerException(messages.getMessage("clay.null.attributeBean"));
+        ComponentBean displayElement = clayContext.getDisplayElement();
+        if (displayElement == null)
+            throw new NullPointerException(messages.getMessage("clay.null.componentBean"));
+        FacesContext facesContext = clayContext.getFacesContext();
+        if (facesContext == null)
+            throw new NullPointerException(messages.getMessage("clay.null.facesContext"));
+        if (attributeBean.getName().equals("validator")) {
+            isFinal = true;
+            
+            UIComponent child = (UIComponent) clayContext.getChild();
+            if (child == null)
+                throw new NullPointerException("child");
+            
+            if (child instanceof EditableValueHolder) {
+                
+                String expr = replaceMnemonic(clayContext);
+                Class[] methodSignature = {
+                    javax.faces.context.FacesContext.class,
+                            javax.faces.component.UIComponent.class,
+                            java.lang.Object.class };
+                            
+                            MethodBinding binding = facesContext.getApplication()
+                            .createMethodBinding(expr, methodSignature);
+                            
+                            ((EditableValueHolder) child)
+                            .setValidator((MethodBinding) binding);
+            } else {
+                log.error(messages.getMessage("property.validator.error", new Object[] {attributeBean}));
+            }
+        }
+        
+        return isFinal;
+    }
+}

Modified: struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/component/chain/PropertyValueChangeListenerCommand.java
URL: http://svn.apache.org/viewcvs/struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/component/chain/PropertyValueChangeListenerCommand.java?rev=165369&r1=165368&r2=165369&view=diff
==============================================================================
--- struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/component/chain/PropertyValueChangeListenerCommand.java (original)
+++ struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/component/chain/PropertyValueChangeListenerCommand.java Fri Apr 29 18:39:50 2005
@@ -1,81 +1,103 @@
-/*
- * Copyright 2005 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.component.chain;
-
-import javax.faces.component.EditableValueHolder;
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-import javax.faces.el.MethodBinding;
-
-import org.apache.commons.chain.Command;
-import org.apache.commons.chain.Context;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.shale.clay.config.beans.AttributeBean;
-import org.apache.shale.clay.config.beans.ComponentBean;
-
-public class PropertyValueChangeListenerCommand extends AbstractCommand
-        implements Command {
-    
-    private static Log log;
-    static {
-        log = LogFactory.getLog(PropertyValueChangeListenerCommand.class);
-    }
-    
-    public boolean execute(Context context) throws Exception {
-        
-        boolean isFinal = false;
-        
-        ClayContext clayContext = (ClayContext) context;
-        if (clayContext == null)
-            throw new NullPointerException(messages.getMessage("clay.null.clayContext"));
-        AttributeBean attributeBean = clayContext.getAttribute();
-        if (attributeBean == null)
-            throw new NullPointerException(messages.getMessage("clay.null.attributeBean"));
-        ComponentBean displayElement = clayContext.getDisplayElement();
-        if (displayElement == null)
-            throw new NullPointerException(messages.getMessage("clay.null.childComponent"));
-        FacesContext facesContext = clayContext.getFacesContext();
-        if (facesContext == null)
-            throw new NullPointerException(messages.getMessage("clay.null.facesContext"));
-        if (attributeBean.getName().equals("valueChangeListener")) {
-            isFinal = true;
-            
-            UIComponent child = (UIComponent) clayContext.getChild();
-            if (child == null)
-                throw new NullPointerException("child");
-            
-            if (child instanceof EditableValueHolder) {
-                
-                String expr = replaceMnemonic(clayContext);
-                Class[] methodSignature = { javax.faces.event.ValueChangeEvent.class };
-                
-                MethodBinding binding = facesContext.getApplication()
-                .createMethodBinding(expr, methodSignature);
-                
-                ((EditableValueHolder) child)
-                .setValueChangeListener((MethodBinding) binding);
-            } else {
-                log.error(messages.getMessage("property.valueChangeListener.error", new Object[] {attributeBean}));
-            }
-        }
-        
-        return isFinal;
-    }
-}
+/*
+ * Copyright 2005 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.component.chain;
+
+import javax.faces.component.EditableValueHolder;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.el.MethodBinding;
+
+import org.apache.commons.chain.Command;
+import org.apache.commons.chain.Context;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.shale.clay.config.beans.AttributeBean;
+import org.apache.shale.clay.config.beans.ComponentBean;
+
+/**
+ * <p>
+ * This <code>Command</code> will create an <code>ValueChangeListener</code>
+ * method binding and assign it to the <code>UIComponent</code> implementing
+ * the <code>EditableValueHolder</code> interface. This <code>Command</code>
+ * is invoked from the {@link AssignPropertiesCommand} chain.
+ * </p>
+ */
+public class PropertyValueChangeListenerCommand extends AbstractCommand
+        implements Command {
+
+    /**
+     * <p>
+     * Common logger utility class
+     * </p>
+     */    
+    private static Log log;
+    static {
+        log = LogFactory.getLog(PropertyValueChangeListenerCommand.class);
+    }
+
+    /**
+     * <p>
+     * Looks to see if the {@link AttributeBean} on the {@link ClayContext} is a
+     * <code>valueChangeListener</code> attribute. If it is, create a
+     * <code>methodBinding</code> and assign it to the component returning a
+     * <code>true</code> value. Otherwise, return a <code>false</code>
+     * value.
+     * </p>
+     */
+    public boolean execute(Context context) throws Exception {
+        
+        boolean isFinal = false;
+        
+        ClayContext clayContext = (ClayContext) context;
+        if (clayContext == null)
+            throw new NullPointerException(messages.getMessage("clay.null.clayContext"));
+        AttributeBean attributeBean = clayContext.getAttribute();
+        if (attributeBean == null)
+            throw new NullPointerException(messages.getMessage("clay.null.attributeBean"));
+        ComponentBean displayElement = clayContext.getDisplayElement();
+        if (displayElement == null)
+            throw new NullPointerException(messages.getMessage("clay.null.childComponent"));
+        FacesContext facesContext = clayContext.getFacesContext();
+        if (facesContext == null)
+            throw new NullPointerException(messages.getMessage("clay.null.facesContext"));
+        if (attributeBean.getName().equals("valueChangeListener")) {
+            isFinal = true;
+            
+            UIComponent child = (UIComponent) clayContext.getChild();
+            if (child == null)
+                throw new NullPointerException("child");
+            
+            if (child instanceof EditableValueHolder) {
+                
+                String expr = replaceMnemonic(clayContext);
+                Class[] methodSignature = { javax.faces.event.ValueChangeEvent.class };
+                
+                MethodBinding binding = facesContext.getApplication()
+                .createMethodBinding(expr, methodSignature);
+                
+                ((EditableValueHolder) child)
+                .setValueChangeListener((MethodBinding) binding);
+            } else {
+                log.error(messages.getMessage("property.valueChangeListener.error", new Object[] {attributeBean}));
+            }
+        }
+        
+        return isFinal;
+    }
+}

Modified: struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/component/chain/PropertyValueCommand.java
URL: http://svn.apache.org/viewcvs/struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/component/chain/PropertyValueCommand.java?rev=165369&r1=165368&r2=165369&view=diff
==============================================================================
--- struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/component/chain/PropertyValueCommand.java (original)
+++ struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/component/chain/PropertyValueCommand.java Fri Apr 29 18:39:50 2005
@@ -1,94 +1,113 @@
-/*
- * Copyright 2005 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.component.chain;
-
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-import javax.faces.el.ValueBinding;
-
-import org.apache.commons.beanutils.BeanUtils;
-import org.apache.commons.chain.Command;
-import org.apache.commons.chain.Context;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.shale.clay.config.beans.AttributeBean;
-import org.apache.shale.clay.config.beans.ComponentBean;
-import org.apache.shale.clay.utils.PropUtils;
-
-public class PropertyValueCommand extends AbstractCommand implements Command {
-    
-    private static Log log;
-    static {
-        log = LogFactory.getLog(PropertyValueCommand.class);
-    }
-    
-    public boolean execute(Context context) throws Exception {
-        
-        boolean isFinal = true;
-        
-        ClayContext clayContext = (ClayContext) context;
-        if (clayContext == null)
-            throw new NullPointerException(messages.getMessage("clay.null.clayContext"));
-        AttributeBean attributeBean = clayContext.getAttribute();
-        if (attributeBean == null)
-            throw new NullPointerException(messages.getMessage("clay.null.attributeBean"));
-        Object child = clayContext.getChild();
-        if (child == null)
-            throw new NullPointerException(messages.getMessage("clay.null.childComponent"));
-        ComponentBean displayElement = clayContext.getDisplayElement();
-        if (displayElement == null)
-            throw new NullPointerException(messages.getMessage("clay.null.componentBean"));
-        FacesContext facesContext = clayContext.getFacesContext();
-        if (facesContext == null)
-            throw new NullPointerException(messages.getMessage("clay.null.facesContext"));
-        if (attributeBean.getValue() != null
-                && (attributeBean.getValue().indexOf('{') > -1 && attributeBean
-                .getValue().indexOf('}') > -1)) {
-            String expr = replaceMnemonic(clayContext);
-            ValueBinding binding = facesContext.getApplication()
-            .createValueBinding(expr);
-            
-            if (attributeBean.useValueLateBinding()
-            && child instanceof UIComponent) {
-                ((UIComponent) child).setValueBinding(attributeBean.getName(),
-                        binding);
-            } else {
-                Object value = binding.getValue(facesContext);
-                try {
-                    BeanUtils
-                            .setProperty(child, attributeBean.getName(), value);
-                } catch (Exception e) {
-                    PropUtils.setProperty(child, attributeBean.getName(),
-                            value, null);
-                }
-                
-            }
-        } else {
-            try {
-                BeanUtils.setProperty(child, attributeBean.getName(),
-                        attributeBean.getValue());
-            } catch (Exception e) {
-                PropUtils.setProperty(child, attributeBean.getName(),
-                        attributeBean.getValue(), null);
-            }
-        }
-        
-        return isFinal;
-    }
-}
+/*
+ * Copyright 2005 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.component.chain;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.el.ValueBinding;
+
+import org.apache.commons.beanutils.BeanUtils;
+import org.apache.commons.chain.Command;
+import org.apache.commons.chain.Context;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.shale.clay.config.beans.AttributeBean;
+import org.apache.shale.clay.config.beans.ComponentBean;
+import org.apache.shale.clay.utils.PropUtils;
+
+/**
+ * <p>
+ * This is the catch all <code>Command</code> to handle all attributes that
+ * are not an "action", "actionListener", "validator" and "valueChangeListener".
+ * This <code>Command</code> is invoked from the
+ * {@link AssignPropertiesCommand} chain.
+ * <p>
+ */
+public class PropertyValueCommand extends AbstractCommand implements Command {
+    
+    private static Log log;
+    static {
+        log = LogFactory.getLog(PropertyValueCommand.class);
+    }
+
+    /**
+     * <p>
+     * Looks at the {@link AttributeBean} on the {@link ClayContext} to see
+     * if the value is a binding EL.  If it is not it just updates the component
+     * with the value.  If the attribute is a value binding expression, then a
+     * <code>ValueBinding</code> is created.  If the attribute uses early binding
+     * the <code>ValueBinding</code> is executed and result applied to the component.
+     * Otherwise, the binding expression is applied to the component in a prepared state.
+     * A <code>true</code> value is always returned because this is the default handler. 
+     * </p>
+     */
+    public boolean execute(Context context) throws Exception {
+        
+        boolean isFinal = true;
+        
+        ClayContext clayContext = (ClayContext) context;
+        if (clayContext == null)
+            throw new NullPointerException(messages.getMessage("clay.null.clayContext"));
+        AttributeBean attributeBean = clayContext.getAttribute();
+        if (attributeBean == null)
+            throw new NullPointerException(messages.getMessage("clay.null.attributeBean"));
+        Object child = clayContext.getChild();
+        if (child == null)
+            throw new NullPointerException(messages.getMessage("clay.null.childComponent"));
+        ComponentBean displayElement = clayContext.getDisplayElement();
+        if (displayElement == null)
+            throw new NullPointerException(messages.getMessage("clay.null.componentBean"));
+        FacesContext facesContext = clayContext.getFacesContext();
+        if (facesContext == null)
+            throw new NullPointerException(messages.getMessage("clay.null.facesContext"));
+        if (attributeBean.getValue() != null
+                && (attributeBean.getValue().indexOf('{') > -1 && attributeBean
+                .getValue().indexOf('}') > -1)) {
+            String expr = replaceMnemonic(clayContext);
+            ValueBinding binding = facesContext.getApplication()
+            .createValueBinding(expr);
+            
+            if (attributeBean.useValueLateBinding()
+            && child instanceof UIComponent) {
+                ((UIComponent) child).setValueBinding(attributeBean.getName(),
+                        binding);
+            } else {
+                Object value = binding.getValue(facesContext);
+                try {
+                    BeanUtils
+                            .setProperty(child, attributeBean.getName(), value);
+                } catch (Exception e) {
+                    PropUtils.setProperty(child, attributeBean.getName(),
+                            value, null);
+                }
+                
+            }
+        } else {
+            try {
+                BeanUtils.setProperty(child, attributeBean.getName(),
+                        attributeBean.getValue());
+            } catch (Exception e) {
+                PropUtils.setProperty(child, attributeBean.getName(),
+                        attributeBean.getValue(), null);
+            }
+        }
+        
+        return isFinal;
+    }
+}



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


Mime
View raw message