You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@shale.apache.org by gv...@apache.org on 2007/03/18 16:23:04 UTC

svn commit: r519627 - in /shale/framework/branches/SHALE_1_0_X/shale-clay/src: main/java/org/apache/shale/clay/parser/builder/ test/java/org/apache/shale/clay/config/ test/resources/org/apache/shale/clay/config/

Author: gvanmatre
Date: Sun Mar 18 08:23:04 2007
New Revision: 519627

URL: http://svn.apache.org/viewvc?view=rev&rev=519627
Log:
Fix for SHALE-426, Implicit mapping of <a> tag appears to be overriding explicit mapping.  Reported by Richard W. Eggert II.

Modified:
    shale/framework/branches/SHALE_1_0_X/shale-clay/src/main/java/org/apache/shale/clay/parser/builder/OutputLinkBuilder.java
    shale/framework/branches/SHALE_1_0_X/shale-clay/src/test/java/org/apache/shale/clay/config/ImplicitMappingTestCase.java
    shale/framework/branches/SHALE_1_0_X/shale-clay/src/test/resources/org/apache/shale/clay/config/implicit.html

Modified: shale/framework/branches/SHALE_1_0_X/shale-clay/src/main/java/org/apache/shale/clay/parser/builder/OutputLinkBuilder.java
URL: http://svn.apache.org/viewvc/shale/framework/branches/SHALE_1_0_X/shale-clay/src/main/java/org/apache/shale/clay/parser/builder/OutputLinkBuilder.java?view=diff&rev=519627&r1=519626&r2=519627
==============================================================================
--- shale/framework/branches/SHALE_1_0_X/shale-clay/src/main/java/org/apache/shale/clay/parser/builder/OutputLinkBuilder.java (original)
+++ shale/framework/branches/SHALE_1_0_X/shale-clay/src/main/java/org/apache/shale/clay/parser/builder/OutputLinkBuilder.java Sun Mar 18 08:23:04 2007
@@ -86,12 +86,13 @@
      */
     protected void encodeBegin(Node node, ElementBean target, ComponentBean root) {
         super.encodeBegin(node, target, root);
-
-        AttributeBean attr = target.getAttribute("value");
-        SymbolBean symbol = target.getSymbol("href");
-        if ((symbol != null && attr != null)
-            && (attr.getValue() == null || attr.getValue().length() == 0)) {
-            createAttribute(attr, "@href", target);
+        if (getComponentType(node).equals(target.getComponentType())) {
+            AttributeBean attr = target.getAttribute("value");
+            SymbolBean symbol = target.getSymbol("href");
+            if ((symbol != null && attr != null)
+                    && (attr.getValue() == null || attr.getValue().length() == 0)) {
+                createAttribute(attr, "@href", target);
+            }
         }
     }
 

Modified: shale/framework/branches/SHALE_1_0_X/shale-clay/src/test/java/org/apache/shale/clay/config/ImplicitMappingTestCase.java
URL: http://svn.apache.org/viewvc/shale/framework/branches/SHALE_1_0_X/shale-clay/src/test/java/org/apache/shale/clay/config/ImplicitMappingTestCase.java?view=diff&rev=519627&r1=519626&r2=519627
==============================================================================
--- shale/framework/branches/SHALE_1_0_X/shale-clay/src/test/java/org/apache/shale/clay/config/ImplicitMappingTestCase.java (original)
+++ shale/framework/branches/SHALE_1_0_X/shale-clay/src/test/java/org/apache/shale/clay/config/ImplicitMappingTestCase.java Sun Mar 18 08:23:04 2007
@@ -25,6 +25,7 @@
 import javax.faces.component.UISelectItem;
 import javax.faces.component.UISelectItems;
 import javax.faces.component.html.HtmlCommandButton;
+import javax.faces.component.html.HtmlCommandLink;
 import javax.faces.component.html.HtmlInputText;
 import javax.faces.component.html.HtmlInputTextarea;
 import javax.faces.component.html.HtmlOutputLabel;
@@ -139,6 +140,22 @@
                 .getAttributes().get("value"));
         assertEquals("target", "_blank", widget.getAttributes().get("target"));
 
+    }
+
+    public void testAnchorOverride() {
+        UIComponent widget = findComponent(clay, "shaleSiteOverride");
+        assertNotNull("HtmlCommandLink", widget);
+        assertTrue("HtmlCommandLink", widget instanceof HtmlCommandLink);
+
+        MethodBinding mb = ((HtmlCommandLink) widget).getAction();
+        assertNotNull("MethodBinding", mb);
+        String exp = mb.getExpressionString();
+        assertNotNull("Expression String", exp);
+        assertEquals("action", "#{test.save}", exp);
+
+        assertNull("value", widget.getAttributes().get("value"));
+        
+        assertEquals("1 child", 1, widget.getChildCount());
     }
 
     public void testCheckBox() {

Modified: shale/framework/branches/SHALE_1_0_X/shale-clay/src/test/resources/org/apache/shale/clay/config/implicit.html
URL: http://svn.apache.org/viewvc/shale/framework/branches/SHALE_1_0_X/shale-clay/src/test/resources/org/apache/shale/clay/config/implicit.html?view=diff&rev=519627&r1=519626&r2=519627
==============================================================================
--- shale/framework/branches/SHALE_1_0_X/shale-clay/src/test/resources/org/apache/shale/clay/config/implicit.html (original)
+++ shale/framework/branches/SHALE_1_0_X/shale-clay/src/test/resources/org/apache/shale/clay/config/implicit.html Sun Mar 18 08:23:04 2007
@@ -42,6 +42,7 @@
       <input id="reset" type="RESET" value="reset"/> 
       <input id="password" type="password" size="16" value="#{@managed-bean-name.password}"/>
     -->
+    <a id="shaleSiteOverride" jsfid="h:commandLink" href="http://shale.apache.org/" action="#{@managed-bean-name.save}">Test</a>
 
 </form>
 <!-- ### clay:remove ### -->