struts-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gvanma...@apache.org
Subject svn commit: r410710 - in /struts/shale/trunk/clay-plugin/src: conf/ java/org/apache/shale/clay/parser/builder/ java/org/apache/shale/clay/parser/builder/chain/ test/org/apache/shale/clay/config/
Date Thu, 01 Jun 2006 01:21:44 GMT
Author: gvanmatre
Date: Wed May 31 18:21:43 2006
New Revision: 410710

URL: http://svn.apache.org/viewvc?rev=410710&view=rev
Log:
Extended Clay's namespace support.

Added:
    struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/parser/builder/JsfDefaultBuilder.java
  (with props)
    struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/parser/builder/chain/JsfDefaultBuilderRule.java
  (with props)
    struts/shale/trunk/clay-plugin/src/test/org/apache/shale/clay/config/address4.html   (with
props)
    struts/shale/trunk/clay-plugin/src/test/org/apache/shale/clay/config/address5.html   (with
props)
Modified:
    struts/shale/trunk/clay-plugin/src/conf/clay-config.xml
    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/chain/shale-builder-config.xml
    struts/shale/trunk/clay-plugin/src/test/org/apache/shale/clay/config/ConfigTestCase.java
    struts/shale/trunk/clay-plugin/src/test/org/apache/shale/clay/config/address1.html
    struts/shale/trunk/clay-plugin/src/test/org/apache/shale/clay/config/address3.html

Modified: struts/shale/trunk/clay-plugin/src/conf/clay-config.xml
URL: http://svn.apache.org/viewvc/struts/shale/trunk/clay-plugin/src/conf/clay-config.xml?rev=410710&r1=410709&r2=410710&view=diff
==============================================================================
--- struts/shale/trunk/clay-plugin/src/conf/clay-config.xml (original)
+++ struts/shale/trunk/clay-plugin/src/conf/clay-config.xml Wed May 31 18:21:43 2006
@@ -24,6 +24,19 @@
       "http://struts.apache.org/dtds/shale-clay-config_1_0.dtd">
 <view>
 
+  <component jsfid="converter" componentType="override">
+     <description>Abstract component definition.</description>
+  </component>
+  <component jsfid="validator" componentType="override">
+     <description>Abstract component definition.</description>
+  </component>
+  <component jsfid="actionListener" componentType="override">
+     <description>Abstract component definition.</description>
+  </component>
+  <component jsfid="valueChangeListener" componentType="override">
+     <description>Abstract component definition.</description>
+  </component>
+
    <component jsfid="baseComponent" componentType="override">
       <description>Abstract component definition extended by baseHtml, token, subview,

          validatorScript, parameter, selectItem, selectItems, inputHidden, column, 
@@ -898,38 +911,47 @@
   <component jsfid="bigDecimalConverter" componentType="javax.faces.BigDecimal">
      <description>Converts a String value into a java.util.BigDecimal type and back
to a String.</description>
   </component>
+  <component jsfid="convertBigDecimal" extends="bigDecimalConverter"/>
 
   <component jsfid="bigIntegerConverter" componentType="javax.faces.BigInteger">
      <description>Converts a String value into a java.util.BigInteger type and back
to a String.</description>
   </component>
+  <component jsfid="convertBigInteger" extends="bigIntegerConverter"/>
 
   <component jsfid="booleanConverter" componentType="javax.faces.Boolean">
      <description>Converts a String value into a java.lang.Boolean type and back to
a String.</description>
   </component>
+  <component jsfid="convertBoolean" extends="booleanConverter"/>
   
   <component jsfid="byteConverter" componentType="javax.faces.Byte">
      <description>Converts a String value into a java.lang.Byte type and back to a
String.</description>
   </component>
+  <component jsfid="convertByte" extends="byteConverter"/>
 
   <component jsfid="characterConverter" componentType="javax.faces.Character">
      <description>Converts a String value into a java.lang.Character type and back
to a String.</description>
   </component>
+  <component jsfid="convertCharacter" extends="characterConverter"/>
   
   <component jsfid="doubleConverter" componentType="javax.faces.Double">
      <description>Converts a String value into a java.lang.Double type and back to
a String.</description>
   </component>
+  <component jsfid="convertDouble" extends="doubleConverter"/>
 
   <component jsfid="floatConverter" componentType="javax.faces.Float">
     <description>Converts a String value into a java.lang.Float type and back to a
String.</description>
   </component>
+  <component jsfid="convertFloat" extends="floatConverter"/>
   
   <component jsfid="integerConverter" componentType="javax.faces.Integer">
      <description>Converts a string value into an java.lang.Integer type and back to
a string.</description>
   </component> 
+  <component jsfid="convertInteger" extends="integerConverter"/>
 
   <component jsfid="longConverter" componentType="javax.faces.Long">
     <description>Converts a String value into a java.lang.Long type and back to a String.</description>
   </component>
+  <component jsfid="convertLong" extends="longConverter"/>
 
   <component jsfid="numberConverter" componentType="javax.faces.Number">
     <description>Converts a String into a number and back to a String.</description>
@@ -968,10 +990,12 @@
        </set>
     </attributes>
   </component>
+  <component jsfid="convertNumber" extends="numberConverter"/>
 
   <component jsfid="shortConverter" componentType="javax.faces.Short">
     <description>Converts a String value into a java.lang.Short type and back to a
String.</description>
   </component>
+  <component jsfid="convertShort" extends="shortConverter"/>
 
 
   <component jsfid="dateTimeConverter" componentType="javax.faces.DateTime" >
@@ -998,7 +1022,8 @@
       </set> 
     </attributes>	
   </component>
-
+  <component jsfid="convertDateTime" extends="dateTimeConverter"/>
+  
 
   <component jsfid="clay" componentType="org.apache.shale.clay.component.Clay" 
         allowBody="false" extends="baseComponent">
@@ -1136,6 +1161,7 @@
        </set>
      </attributes>
   </component>
+  <component jsfid="validateDoubleRange" extends="doubleRangeValidator"/>
 
   <component jsfid="lengthValidator" componentType="javax.faces.Length">
      <description>Verifies the submitted string value is greater than and not less
than the specified minimum and maximum values.</description>
@@ -1148,6 +1174,7 @@
        </set>
      </attributes>  
   </component>
+  <component jsfid="validateLength" extends="lengthValidator"/>
 
   <component jsfid="longRangeValidator" componentType="javax.faces.LongRange">
      <description>Verifies the submitted value is a long within the specified minimum
and maximum values.</description>
@@ -1160,5 +1187,6 @@
        </set>
      </attributes>
   </component>
+  <component jsfid="validateLongRange" extends="longRangeValidator"/>
 
 </view>

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=410710&r1=410709&r2=410710&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
Wed May 31 18:21:43 2006
@@ -77,7 +77,7 @@
     protected void addConverter(Node node, ElementBean target) {
        ConverterBean targetConverter = new ConverterBean();
        
-       String jsfid = (String) node.getAttributes().get("jsfid");
+       String jsfid = getJsfid(node);
        targetConverter.setJsfid(jsfid);
 
        // resolve inheritance and attribute overrides
@@ -96,7 +96,7 @@
     protected void addValidator(Node node, ElementBean target) {
        ValidatorBean targetValidator = new ValidatorBean();
        
-       String jsfid = (String) node.getAttributes().get("jsfid");
+       String jsfid = getJsfid(node);
        targetValidator.setJsfid(jsfid);
        
        // resolve inheritance and attribute overrides
@@ -114,7 +114,7 @@
     protected void addActionListener(Node node, ElementBean target) {
        ActionListenerBean targetActionListener = new ActionListenerBean();
        
-       String jsfid = (String) node.getAttributes().get("jsfid");
+       String jsfid = getJsfid(node);
        targetActionListener.setJsfid(jsfid);
        
        // resolve inheritance and attribute overrides
@@ -132,7 +132,7 @@
     protected void addValueChangeListener(Node node, ElementBean target) {
        ValueChangeListenerBean targetValueChangeListener = new ValueChangeListenerBean();
        
-       String jsfid = (String) node.getAttributes().get("jsfid");
+       String jsfid = getJsfid(node);
        targetValueChangeListener.setJsfid(jsfid);
        
        // resolve inheritance and attribute overrides

Added: 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=410710&view=auto
==============================================================================
--- struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/parser/builder/JsfDefaultBuilder.java
(added)
+++ struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/parser/builder/JsfDefaultBuilder.java
Wed May 31 18:21:43 2006
@@ -0,0 +1,275 @@
+/*
+ * 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.parser.builder;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.shale.clay.config.beans.ActionListenerBean;
+import org.apache.shale.clay.config.beans.AttributeBean;
+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.ValidatorBean;
+import org.apache.shale.clay.config.beans.ValueChangeListenerBean;
+import org.apache.shale.clay.parser.Node;
+import org.apache.shale.util.Tags;
+
+/**
+ * <p>A generic builder that maps the markup node name to the jsfid.  The extends attribute

+ * can be used to override the default mapping to provide meta-data inheritance.  The builder

+ * handles child nodes common to JSF and shale components.</p>
+ *
+ */
+public class JsfDefaultBuilder extends ElementBuilder {
+
+    /**
+     * <p>Utility class that helps evaluate binding expressions.</p> 
+     */
+    private Tags tagsUtil = new Tags();
+    
+    
+    /**
+     * <p>Factory method that creates a {@link ElementBean} from a {@link Node}.</p>
+     */    
+    public ElementBean createElement(Node node) {
+        ElementBean target = new ElementBean();
+        target.setJsfid(getJsfid(node));
+        target.setRenderId(getRenderId());
+        
+        return target;
+    }
+
+    
+    /**
+     * @inheritDoc
+     */
+    protected void addConverter(Node node, ElementBean target) {
+        ConverterBean targetConverter = new ConverterBean();
+        
+        String jsfid = getJsfid(node);
+        targetConverter.setJsfid(jsfid);
+        
+        String converterId = null;
+        if ((converterId = (String) node.getAttributes().get("converterId")) != null) {
+            targetConverter.setComponentType(tagsUtil.evalString(converterId));    
+        }
+        
+        // resolve inheritance and attribute overrides
+        if (node.getAttributes().containsKey("extends") && !jsfid.equals("converter"))
{
+            realizeComponent(node, targetConverter);     
+        }
+        
+        //attach to the target element
+        target.addConverter(targetConverter);
+        
+    }
+    
+    
+    /**
+     * @inheritDoc
+     */
+    protected void addValidator(Node node, ElementBean target) {
+        ValidatorBean targetValidator = new ValidatorBean();
+        
+        String jsfid = getJsfid(node);
+        targetValidator.setJsfid(jsfid);
+        
+        String validatorId = null;
+        if ((validatorId = (String) node.getAttributes().get("validatorId")) != null) {
+            targetValidator.setComponentType(tagsUtil.evalString(validatorId));    
+        }
+        
+        // resolve inheritance and attribute overrides
+        if (node.getAttributes().containsKey("extends") || !jsfid.equals("validator")) {
+            realizeComponent(node, targetValidator);     
+        }
+        //attach to the target element
+        target.addValidator(targetValidator);
+        
+    }
+
+    /**
+     * @inheritDoc
+     */
+    protected void addActionListener(Node node, ElementBean target) {
+        ActionListenerBean targetActionListener = new ActionListenerBean();
+        
+        String jsfid = getJsfid(node);
+        targetActionListener.setJsfid(jsfid);
+        
+        String type = null;
+        if ((type = (String) node.getAttributes().get("type")) != null) {
+            targetActionListener.setComponentType(tagsUtil.evalString(type));    
+        }
+        
+        // resolve inheritance and attribute overrides
+        if (node.getAttributes().containsKey("extends") || !jsfid.equals("actionListener"))
{
+            realizeComponent(node, targetActionListener);     
+        }
+        //attach to the target element
+        target.addActionListener(targetActionListener);
+        
+    }
+
+    /**
+     * @inheritDoc
+     */
+    protected void addValueChangeListener(Node node, ElementBean target) {
+        ValueChangeListenerBean targetValueChangeListener = new ValueChangeListenerBean();
+        
+        String jsfid = getJsfid(node);
+        targetValueChangeListener.setJsfid(jsfid);
+        
+        String type = null;
+        if ((type = (String) node.getAttributes().get("type")) != null) {
+            targetValueChangeListener.setComponentType(tagsUtil.evalString(type));    
+        }
+        
+        // resolve inheritance and attribute overrides
+        if (node.getAttributes().containsKey("extends") || !jsfid.equals("valueChangeListener"))
{
+            realizeComponent(node, targetValueChangeListener);     
+        }
+        
+        //attach to the target element
+        target.addValueChangeListener(targetValueChangeListener);
+    }
+
+    /**
+     * <p>Adds markup &lt;clay:symbol&gt; to the <code>target</code>
+     * {@link org.apache.shale.clay.config.beans.ElementBean}.
+     * </p>
+     */
+    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);    
+        }
+    }
+
+    /**
+     * <p>Adds markup &lt;f:attribute&gt; to the <code>target</code>
+     * {@link org.apache.shale.clay.config.beans.ElementBean}.
+     * </p>
+     */
+    protected void addAttribute(Node node, ElementBean target) {
+        String name = (String) target.getAttributes().get("name");
+        String value = (String) target.getAttributes().get("value");
+        
+        AttributeBean attr = null;
+        if ((attr = target.getAttribute(name)) != null) {
+            createAttribute(attr, value, target);       
+        } else {
+            attr = new AttributeBean();
+            attr.setName(name);
+            attr.setValue(value);
+            attr.setBindingType(AttributeBean.BINDING_TYPE_EARLY);
+            target.addAttribute(attr);
+        }    
+    }
+
+    /**
+     * <p>Adds markup &lt;f:facet&gt; to the <code>target</code>'s
+     * child {@link org.apache.shale.clay.config.beans.ElementBean}.
+     * </p>
+     */
+    protected void addFacet(Node node, ElementBean target) {
+        String facetName = (String) node.getAttributes().get("name");
+        Iterator ci = node.getChildren().iterator();
+        // look for the first well-formed node.  only one under
+        // a facet.  Call back on the current builder
+        while (ci.hasNext()) {
+            Node child = (Node) ci.next();
+            if (child.isWellFormed()) {
+                Builder childBuilder = child.getBuilder();     
+                ElementBean nextTarget = childBuilder.createElement(child);
+                nextTarget.setFacetName(facetName);
+                target.addChild(nextTarget);
+                childBuilder.encode(child, nextTarget, target);
+                break;
+            }
+        }
+    }
+    
+   
+    /**
+     * <p>Build's a <code>target</code> {@link ElementBean} from a {@link
Node}. The 
+     * following child nodes are handles outside of the <code>encodeChildren</code>
+     * method: symbol, facet, attribute, convert, validate, actionListener, 
+     * and valueChangeListener.
+     * </p>
+     */
+    protected void encodeBegin(Node node, ElementBean target, ComponentBean root) {
+        assignNode(node, target);
+        
+        List deleteList = new ArrayList();
+        Iterator ci = node.getChildren().iterator();
+        while (ci.hasNext()) {
+            Node child = (Node) ci.next();
+            if (child.isWellFormed() && child.getName() != null) {
+                if (child.getName().equals("symbol")) {
+                    addSymbol(child, target);
+                    deleteList.add(child);    
+                } else if (child.getName().equals("facet")) {
+                    addFacet(child, target);
+                    deleteList.add(child);    
+                } else if (child.getName().equals("attribute")) {
+                    addAttribute(child, target);
+                    deleteList.add(child);    
+                } else if (child.getName().startsWith("convert")) {
+                    addConverter(child, target);
+                    deleteList.add(child);    
+                } else if (child.getName().startsWith("validate")) {
+                    addValidator(child, target);
+                    deleteList.add(child);    
+                } else if (child.getName().equals("actionListener")) {
+                    addActionListener(child, target);
+                    deleteList.add(child);    
+                } else if (child.getName().equals("valueChangeListener")) {
+                    addValueChangeListener(child, target);
+                    deleteList.add(child);    
+                } 
+            } else {
+                
+                // remove white space
+                deleteList.add(child);
+            }
+        }
+        
+        ci = deleteList.iterator();
+        while (ci.hasNext())
+            node.getChildren().remove(ci.next());
+        
+    }
+
+    /**
+     * <p>Returns the <code>jsfid</code> from the {@link Node} The <code>extends</code>

+     * attribute is giving the first order of evaluation.  If empty, the <code>node</code>'s

+     * name is assigned to the jsfid.</p>
+     */
+    protected String getJsfid(Node node) {
+        String jsfid = null;
+        if ((jsfid = (String) node.getAttributes().get("extends")) != null) {
+            return jsfid;    
+        } else
+            return node.getName();
+    }
+    
+}

Propchange: struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/parser/builder/JsfDefaultBuilder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/parser/builder/JsfDefaultBuilder.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Added: struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/parser/builder/chain/JsfDefaultBuilderRule.java
URL: http://svn.apache.org/viewvc/struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/parser/builder/chain/JsfDefaultBuilderRule.java?rev=410710&view=auto
==============================================================================
--- struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/parser/builder/chain/JsfDefaultBuilderRule.java
(added)
+++ struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/parser/builder/chain/JsfDefaultBuilderRule.java
Wed May 31 18:21:43 2006
@@ -0,0 +1,54 @@
+/*
+ * 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.parser.builder.chain;
+
+import org.apache.commons.chain.Command;
+import org.apache.commons.chain.Context;
+import org.apache.shale.clay.parser.builder.Builder;
+import org.apache.shale.clay.parser.builder.JsfDefaultBuilder;
+
+
+/**
+ * <p>Delegates all handling to a common 
+ * {@link org.apache.shale.clay.parser.builder.JsfDefaultBuilder} that can 
+ * transform markup that looks like JSP tags to a graph of 
+ * {@link org.apache.shale.clay.config.beans.InnerComponentBean} beans.</p>
+ *
+ */
+public class JsfDefaultBuilderRule implements Command {
+
+    /**
+     * <p>Generic {@link Builder} that handles JSP style of markup's.</p>
+     */
+    private static final Builder[] builders = {new JsfDefaultBuilder()};
+
+    /**
+     * <p>Assigns handling of the markup to {@link org.apache.shale.clay.parser.builder.JsfDefaultBuilder}
+     * without condition.</p>
+     */
+    public boolean execute(Context context) throws Exception {
+        
+        BuilderRuleContext builderRuleContext = (BuilderRuleContext) context;
+        builderRuleContext.setBuilder(builders[0]);
+        
+        return true;
+    }
+
+    
+}

Propchange: struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/parser/builder/chain/JsfDefaultBuilderRule.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/parser/builder/chain/JsfDefaultBuilderRule.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Modified: struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/parser/builder/chain/shale-builder-config.xml
URL: http://svn.apache.org/viewvc/struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/parser/builder/chain/shale-builder-config.xml?rev=410710&r1=410709&r2=410710&view=diff
==============================================================================
--- struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/parser/builder/chain/shale-builder-config.xml
(original)
+++ struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/parser/builder/chain/shale-builder-config.xml
Wed May 31 18:21:43 2006
@@ -39,8 +39,24 @@
     <command  className="org.apache.shale.clay.parser.builder.chain.DefaultBuilderRule"/>
   </chain>
 
-  <chain           name="http://struts.apache.org/dtds/shale-clay-config">
+  <chain           name="http://java.sun.com/jsf/core">
+    <command  className="org.apache.shale.clay.parser.builder.chain.JsfDefaultBuilderRule"/>
+  </chain>
+
+  <chain           name="http://java.sun.com/jsf/html">
+    <command  className="org.apache.shale.clay.parser.builder.chain.JsfDefaultBuilderRule"/>
+  </chain>
+
+  <chain           name="http://struts.apache.org/shale/core">
+    <command  className="org.apache.shale.clay.parser.builder.chain.JsfDefaultBuilderRule"/>
+  </chain>
+
+  <chain           name="http://struts.apache.org/shale/clay-plugin/html">
     <command  className="org.apache.shale.clay.parser.builder.chain.ClayNamespaceBuilderRule"/>
+  </chain>
+
+  <chain           name="http://struts.apache.org/shale/clay-plugin">
+    <command  className="org.apache.shale.clay.parser.builder.chain.JsfDefaultBuilderRule"/>
   </chain>
 
 

Modified: struts/shale/trunk/clay-plugin/src/test/org/apache/shale/clay/config/ConfigTestCase.java
URL: http://svn.apache.org/viewvc/struts/shale/trunk/clay-plugin/src/test/org/apache/shale/clay/config/ConfigTestCase.java?rev=410710&r1=410709&r2=410710&view=diff
==============================================================================
--- struts/shale/trunk/clay-plugin/src/test/org/apache/shale/clay/config/ConfigTestCase.java
(original)
+++ struts/shale/trunk/clay-plugin/src/test/org/apache/shale/clay/config/ConfigTestCase.java
Wed May 31 18:21:43 2006
@@ -49,30 +49,30 @@
         for (int i = 0; i < COMPONENTS.length; i++) {
             ComponentBean bean = standardConfigBean.getElement(((String[])COMPONENTS[i])[0]);
             assertNotNull("component", bean);
-            assertEquals("component.jsfid", bean.getJsfid(), ((String[])COMPONENTS[i])[0]);

-            assertEquals("component.componentType", bean.getComponentType(), ((String[])COMPONENTS[i])[1]);
+            assertEquals("component.jsfid",((String[])COMPONENTS[i])[0],  bean.getJsfid());

+            assertEquals("component.componentType", ((String[])COMPONENTS[i])[1], bean.getComponentType());
         }
 
         //verify converters where loaded
         for (int i = 0; i < CONVERTERS.length; i++) {
             ComponentBean bean = standardConfigBean.getElement(((String[])CONVERTERS[i])[0]);
             assertNotNull("converter", bean);
-            assertEquals("converter.jsfid", bean.getJsfid(), ((String[])CONVERTERS[i])[0]);

-            assertEquals("converter.componentType", bean.getComponentType(), ((String[])CONVERTERS[i])[1]);
+            assertEquals("converter.jsfid", ((String[])CONVERTERS[i])[0], bean.getJsfid());

+            assertEquals("converter.componentType", ((String[])CONVERTERS[i])[1], bean.getComponentType());
         }
 
         //verify validators where loaded 
         for (int i = 0; i < VALIDATORS.length; i++) {
             ComponentBean bean = standardConfigBean.getElement(((String[])VALIDATORS[i])[0]);
             assertNotNull("validator", bean);
-            assertEquals("validator.jsfid", bean.getJsfid(), ((String[])VALIDATORS[i])[0]);

-            assertEquals("validator.componentType", bean.getComponentType(), ((String[])VALIDATORS[i])[1]);
+            assertEquals("validator.jsfid", ((String[])VALIDATORS[i])[0], bean.getJsfid());

+            assertEquals("validator.componentType", ((String[])VALIDATORS[i])[1], bean.getComponentType());
         }
 
     }
 
     //data that is used to verify the inheritance is working from the XML file.
-    //jsfid, componentType, facetName, allowBody, attributes[], 
+    //jsfid || id, componentType, facetName, allowBody, attributes[], 
     //aggregates (converters, children, validators, actionListeners, valueChangeListeners)
     protected static final Object[] CUSTOM_XML_COMPONENTS =  {
              new Object[] {"street1Label","javax.faces.HtmlOutputLabel", null, "false", 
@@ -145,7 +145,7 @@
 
     
     //Data that is used to verify the inheritance is working from the HTML file.
-    //jsfid, componentType, facetName, allowBody, attributes[]
+    //jsfid || id, componentType, facetName, allowBody, attributes[]
     //aggregates (converters, children, validators, actionListeners, valueChangeListeners)
     protected static final Object[] CUSTOM_HTML_COMPONENTS =  {
              new Object[] {"street1Label","javax.faces.HtmlOutputLabel", null, "false", 
@@ -232,7 +232,7 @@
         while (ci.hasNext()) {
            ElementBean child = (ElementBean) ci.next();
            //look for a component that we have setup to test
-           checkComponent(child, CUSTOM_XML_COMPONENTS);    
+           checkComponent(child, CUSTOM_XML_COMPONENTS, true);    
         }
     }
     
@@ -252,7 +252,7 @@
         while (ci.hasNext()) {
            ElementBean child = (ElementBean) ci.next();
            //look for a component that we have setup to test
-           checkComponent(child, CUSTOM_HTML_COMPONENTS);    
+           checkComponent(child, CUSTOM_HTML_COMPONENTS, true);    
         } 
         
     }
@@ -273,7 +273,7 @@
         while (ci.hasNext()) {
            ElementBean child = (ElementBean) ci.next();
            //look for a component that we have setup to test
-           checkComponent(child, CUSTOM_HTML_COMPONENTS);    
+           checkComponent(child, CUSTOM_HTML_COMPONENTS, true);    
         } 
         
     }
@@ -293,11 +293,45 @@
         while (ci.hasNext()) {
            ElementBean child = (ElementBean) ci.next();
            //look for a component that we have setup to test
-           checkComponent(child, CUSTOM_HTML_COMPONENTS);    
+           checkComponent(child, CUSTOM_HTML_COMPONENTS, true);    
         } 
         
     }
     
+    public void testLoadXHTMLJsfHtmlCore4() {
+
+        //loads the default and the custom address config file
+        loadConfigFile("/org/apache/shale/clay/config/address-config.xml");
+
+        ComponentBean bean = htmlTemplateConfigBean.getElement("/org/apache/shale/clay/config/address4.html");

+        assertNotNull(bean);
+
+        Iterator ci = bean.getChildrenIterator();
+        while (ci.hasNext()) {
+           ElementBean child = (ElementBean) ci.next();
+           //look for a component that we have setup to test
+           checkComponent(child, CUSTOM_HTML_COMPONENTS, true);    
+        } 
+        
+    }
+
+    public void testLoadXHTMLJsfHtmlCore5() {
+
+        //loads the default and the custom address config file
+        loadConfigFile("/org/apache/shale/clay/config/address-config.xml");
+
+        ComponentBean bean = htmlTemplateConfigBean.getElement("/org/apache/shale/clay/config/address5.html");

+        assertNotNull(bean);
+
+        Iterator ci = bean.getChildrenIterator();
+        while (ci.hasNext()) {
+           ElementBean child = (ElementBean) ci.next();
+           //look for a component that we have setup to test
+           checkComponent(child, CUSTOM_HTML_COMPONENTS, false);    
+        } 
+        
+    }
+
     
     
     //test a full xml view including a html template (on-demand)
@@ -316,22 +350,22 @@
             AttributeBean attr = null;
             if (child.getId().equals("htmlBegin")) {
                 attr = child.getAttribute("value");
-                assertEquals(attr.getValue(), "<html>");
+                assertEquals("<html>", attr.getValue());
             } else if (child.getId().equals("htmlEnd")) {
                 attr = child.getAttribute("value");
-                assertEquals(attr.getValue(), "</html>");
+                assertEquals("</html>", attr.getValue());
             } else if (child.getId().equals("header")) {
                 attr = child.getAttribute("value");
-                assertEquals(attr.getValue(), "<head><title>Testing</title></head>");
+                assertEquals("<head><title>Testing</title></head>",
attr.getValue());
             } else if (child.getId().equals("bodyBegin")) {
                 attr = child.getAttribute("value");
-                assertEquals(attr.getValue(), "<body>");
+                assertEquals("<body>", attr.getValue());
             } else if (child.getId().equals("bodyEnd")) {
                 attr = child.getAttribute("value");
-                assertEquals(attr.getValue(), "</body>");
+                assertEquals("</body>", attr.getValue());
             } else if (child.getId().equals("content")) {
                 //look for a component that we have setup to test
-                checkComponent(child, CUSTOM_HTML_COMPONENTS); 
+                checkComponent(child, CUSTOM_HTML_COMPONENTS, true); 
             }
         } 
     }
@@ -359,22 +393,22 @@
             AttributeBean attr = null;
             if (child.getId().equals("htmlBegin")) {
                 attr = child.getAttribute("value");
-                assertEquals(attr.getValue(), "<html>");
+                assertEquals("<html>", attr.getValue());
             } else if (child.getId().equals("htmlEnd")) {
                 attr = child.getAttribute("value");
-                assertEquals(attr.getValue(), "</html>");
+                assertEquals("</html>", attr.getValue());
             } else if (child.getId().equals("header")) {
                 attr = child.getAttribute("value");
-                assertEquals(attr.getValue(), "<head><title>Testing</title></head>");
+                assertEquals("<head><title>Testing</title></head>",
attr.getValue());
             } else if (child.getId().equals("bodyBegin")) {
                 attr = child.getAttribute("value");
-                assertEquals(attr.getValue(), "<body>");
+                assertEquals("<body>", attr.getValue());
             } else if (child.getId().equals("bodyEnd")) {
                 attr = child.getAttribute("value");
-                assertEquals(attr.getValue(), "</body>");
+                assertEquals("</body>", attr.getValue());
             } else if (child.getId().equals("content")) {
                 //look for a component that we have setup to test
-                checkComponent(child, CUSTOM_HTML_COMPONENTS); 
+                checkComponent(child, CUSTOM_HTML_COMPONENTS, true); 
             }
         } 
         
@@ -382,8 +416,16 @@
     
  
     // checks a meta components realized state against the assumed values
-    protected void checkComponent(ComponentBean bean, Object[] knownGoodStates) {
-       int indx = indexOf(bean.getJsfid(), knownGoodStates);
+    protected void checkComponent(ComponentBean bean, Object[] knownGoodStates, boolean useJsfid)
{
+       
+       String sarg = null;
+       int indx = -1;
+       if (useJsfid)
+          sarg = bean.getJsfid();
+       else
+          sarg = bean.getId();
+          
+       indx = indexOf(sarg, knownGoodStates);
              
        int converterCnt = -1;
        int childrenCnt = -1;
@@ -395,26 +437,32 @@
        if (indx > -1) {
             Object[] compData = (Object[]) knownGoodStates[indx];
             
-            String jsfid = (String) compData[0];
-            assertEquals("check.jsfid", jsfid, bean.getJsfid());
+            
+            if (useJsfid) {
+               String jsfid = (String) compData[0];
+               assertEquals("check.jsfid for" + sarg, jsfid, bean.getJsfid());
+            } else {
+                String id = (String) compData[0];
+                assertEquals("check.id for " + sarg, id, bean.getId());                
+            }
 
             String componentType = (String) compData[1];
-            assertEquals("chekc.componentType", componentType, bean.getComponentType());
+            assertEquals("check.componentType for " + sarg, componentType, bean.getComponentType());
 
             String facetName = (String) compData[2];
-            assertEquals("check.facetName", facetName, bean.getFacetName());
+            assertEquals("check.facetName for " + sarg, facetName, bean.getFacetName());
 
             String allowBody = (String) compData[3];
-            assertEquals("check.allowBody", allowBody, bean.getAllowBody());
+            assertEquals("check.allowBody for " + sarg, allowBody, bean.getAllowBody());
 
             Object[] attributes = (Object[]) compData[4];
             for (int i = 0; i < attributes.length; i++) {
                 String[] valuepair = (String[]) attributes[i];
 
                 AttributeBean attr = bean.getAttribute(valuepair[0]);
-                assertNotNull("check.attribute", attr);
+                assertNotNull("check.attribute for " + sarg, attr);
                 //System.out.println("\t" + attr.toString());
-                assertEquals("check.attribute.value", attr.getValue(), valuepair[1]);
+                assertEquals("check.attribute.value for " + sarg, valuepair[1], attr.getValue());
             }
             
             // the know aggregate object counts
@@ -429,49 +477,49 @@
        
         if (bean.getConverter() !=  null) {
             if (converterCnt > -1)
-               assertEquals("check.converter.cnt", converterCnt, 1);
+               assertEquals("check.converter.cnt for " + sarg, 1, converterCnt);
             
-            checkComponent(bean.getConverter(), knownGoodStates);    
+            checkComponent(bean.getConverter(), knownGoodStates, useJsfid);    
         }
         
         if (childrenCnt > -1) {
-           assertEquals("check.children.cnt", childrenCnt, bean.getChildren().size());  
 
+           assertEquals("check.children.cnt for " + sarg, childrenCnt, bean.getChildren().size());
   
         }
         
         Iterator ci = bean.getChildrenIterator();
         while (ci.hasNext()) {
            ComponentBean child = (ComponentBean) ci.next();
-           checkComponent(child, knownGoodStates);
+           checkComponent(child, knownGoodStates, useJsfid);
         }
 
         if (validatorCnt > -1) {
-            assertEquals("check.validator.cnt", validatorCnt, bean.getValidators().size());
   
+            assertEquals("check.validator.cnt for " + sarg, validatorCnt, bean.getValidators().size());
   
         }
         
         ci = bean.getValidatorIterator();
         while (ci.hasNext()) {
            ComponentBean child = (ComponentBean) ci.next();
-           checkComponent(child, knownGoodStates);
+           checkComponent(child, knownGoodStates, useJsfid);
         }
 
         if (actionListenerCnt > -1) {
-            assertEquals("check.actionListener.cnt", actionListenerCnt, bean.getActionListeners().size());
   
+            assertEquals("check.actionListener.cnt for " + sarg, actionListenerCnt, bean.getActionListeners().size());
   
         }
         
         ci = bean.getActionListenerIterator();
         while (ci.hasNext()) {
            ComponentBean child = (ComponentBean) ci.next();
-           checkComponent(child, knownGoodStates);
+           checkComponent(child, knownGoodStates, useJsfid);
         }
 
         if (valueChangeListenerCnt > -1) {
-            assertEquals("check.valueChangeListener.cnt", valueChangeListenerCnt, bean.getValueChangeListeners().size());
   
+            assertEquals("check.valueChangeListener.cnt for " + sarg, valueChangeListenerCnt,
bean.getValueChangeListeners().size());    
         }
                
         ci = bean.getValueChangeListenerIterator();
         while (ci.hasNext()) {
            ComponentBean child = (ComponentBean) ci.next();
-           checkComponent(child, knownGoodStates);
+           checkComponent(child, knownGoodStates, useJsfid);
         }
 
     }

Modified: struts/shale/trunk/clay-plugin/src/test/org/apache/shale/clay/config/address1.html
URL: http://svn.apache.org/viewvc/struts/shale/trunk/clay-plugin/src/test/org/apache/shale/clay/config/address1.html?rev=410710&r1=410709&r2=410710&view=diff
==============================================================================
--- struts/shale/trunk/clay-plugin/src/test/org/apache/shale/clay/config/address1.html (original)
+++ struts/shale/trunk/clay-plugin/src/test/org/apache/shale/clay/config/address1.html Wed
May 31 18:21:43 2006
@@ -1,5 +1,5 @@
 <form>
-  <table xmlns:clay="http://struts.apache.org/dtds/shale-clay-config">
+  <table xmlns:clay="http://struts.apache.org/shale/clay-plugin/html">
      <tr>
         <td><clay:element jsfid="street1Label"/></td>
         <td><clay:element jsfid="street1">

Modified: struts/shale/trunk/clay-plugin/src/test/org/apache/shale/clay/config/address3.html
URL: http://svn.apache.org/viewvc/struts/shale/trunk/clay-plugin/src/test/org/apache/shale/clay/config/address3.html?rev=410710&r1=410709&r2=410710&view=diff
==============================================================================
--- struts/shale/trunk/clay-plugin/src/test/org/apache/shale/clay/config/address3.html (original)
+++ struts/shale/trunk/clay-plugin/src/test/org/apache/shale/clay/config/address3.html Wed
May 31 18:21:43 2006
@@ -1,5 +1,5 @@
 <form>
-  <table xmlns:clay="http://struts.apache.org/dtds/shale-clay-config">
+  <table xmlns:clay="http://struts.apache.org/shale/clay-plugin/html">
      <tr>
         <td>
         	<clay:element jsfid="baseLabel"> 

Added: struts/shale/trunk/clay-plugin/src/test/org/apache/shale/clay/config/address4.html
URL: http://svn.apache.org/viewvc/struts/shale/trunk/clay-plugin/src/test/org/apache/shale/clay/config/address4.html?rev=410710&view=auto
==============================================================================
--- struts/shale/trunk/clay-plugin/src/test/org/apache/shale/clay/config/address4.html (added)
+++ struts/shale/trunk/clay-plugin/src/test/org/apache/shale/clay/config/address4.html Wed
May 31 18:21:43 2006
@@ -0,0 +1,38 @@
+<form>
+  <table xmlns:h="http://java.sun.com/jsf/html">
+     <tr>
+        <td><h:outputLabel extends="street1Label"/></td>
+        <td><h:inputText extends="street1" size="45"/>
+        </td>
+        <td><h:message extends="street1Message"/></td>
+     </tr>
+     <tr>
+        <td><h:outputLabel extends="street2Label"/></td>
+        <td><h:inputText extends="street2" size="45"/>
+        </td>
+        <td><h:message extends="street2Message"/></td>
+     </tr>
+     <tr>
+        <td><h:outputLabel extends="cityLabel"/></td>
+        <td><h:inputText extends="city" size="25"/>
+        </td>
+        <td><h:message extends="cityMessage"/></td>
+     </tr>
+     <tr>
+        <td><h:outputLabel extends="stateLabel"/></td>
+        <td>
+            <h:selectOneMenu extends="state"/> 
+        </td>
+        <td><h:message extends="stateMessage"/></td>
+     </tr>
+     <tr>
+        <td><h:outputLabel extends="zipLabel"/></td>
+        <td><h:inputText extends="zip" size="9"/>
+        </td>
+        <td><h:message extends="zipMessage"/></td>
+     </tr>
+     <tr>
+        <td colspan=3><h:commandButton extends="saveCommand"/></td> 
+     </tr>
+  </table>
+</form>
\ No newline at end of file

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

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

Added: struts/shale/trunk/clay-plugin/src/test/org/apache/shale/clay/config/address5.html
URL: http://svn.apache.org/viewvc/struts/shale/trunk/clay-plugin/src/test/org/apache/shale/clay/config/address5.html?rev=410710&view=auto
==============================================================================
--- struts/shale/trunk/clay-plugin/src/test/org/apache/shale/clay/config/address5.html (added)
+++ struts/shale/trunk/clay-plugin/src/test/org/apache/shale/clay/config/address5.html Wed
May 31 18:21:43 2006
@@ -0,0 +1,74 @@
+<form>
+     <table xmlns:f="http://java.sun.com/jsf/core" 
+         xmlns:h="http://java.sun.com/jsf/html">     
+       <tr>
+        <td>
+        	<h:outputLabel id="street1Label" value="Street 1:" for="street1" extends="baseLabel"/>
+        </td>
+        <td>
+             <h:inputText id="street1" value="#{@managed-bean-name.address1}" required="true"
size="45" maxlength="50"/> 
+        </td>
+        <td>
+        	<h:message id="street1Message" for="street1" extends="baseMessage"/> 
+        </td>
+     </tr>
+     <tr>
+        <td>
+        	<h:outputLabel id="street2Label" value="Street 2:" for="street2" extends="baseLabel"/>

+        </td>
+        <td>
+	        <h:inputText id="street2" value="#{@managed-bean-name.address2}" required="true"
size="45" maxlength="50/> 
+        </td>
+        <td>
+            <h:message id="street2Message" for="street2" extends="baseMessage"/> 
+        </td>
+     </tr>
+     <tr>
+        <td>
+        	<h:outputLabel id="cityLabel" for="city" value="City:" extends="baseLabel"/>

+        </td>
+        <td> 
+            <h:inputText id="city" value="#{@managed-bean-name.city}" size="25" maxlength="30"
required="true"/> 
+        </td>
+        <td>
+        	<h:message id="cityMessage" for="city" extends="baseMessage"/> 
+        </td>
+     </tr>
+     <tr>
+        <td>
+           <h:outputLabel id="stateLabel" value="State:" for="state" extends="baseLabel"/>

+        </td>
+        <td>
+            <h:selectOneMenu id="state" value="#{@managed-bean-name.state}" required="true">
 
+	           <f:selectItem itemLabel="Colorado" itemValue="CO"/>
+	           <f:selectItem itemLabel="Illinois" itemValue="IL"/> 
+	        </h:selectOneMenu>
+        </td>
+        <td>
+        	<h:message id="stateMessage" for="state" extends="baseMessage"/> 
+        </td>
+     </tr>
+     <tr>
+        <td>
+        	<h:outputLabel id="zipLabel" for="zip" value="Zip:" extends="baseLabel"/>

+        </td>
+        <td>  
+             <h:inputText id="zip" value="#{@managed-bean-name.zip}" maxlength="9" size="9"
valueChangeListener="#{@managed-bean-name.zipValueChange}"> 
+		        <f:convertInteger/>
+	            <f:validateLongRange minimum="80000" maximum="80125"/>
+		        <f:valueChangeListener type="org.apache.shale.clay.config.TestValueChangeListener"/>
+	        </h:inputText>      
+        </td>
+        <td>
+        	<h:message id="zipMessage" for="zip" value="zip" extends="baseMessage"/> 
+        </td>
+     </tr>
+     <tr>
+        <td colspan="3">
+            <h:commandButton id="saveCommand" value="Save" action="#{@managed-bean-name.save}"
actionListener="#{@managed-bean-name.saveAction}">
+                <f:actionListener type="org.apache.shale.clay.config.TestActionListener"/>
+            </h:commandButton> 
+        </td> 
+     </tr>
+  </table>
+</form>
\ No newline at end of file

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

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



Mime
View raw message