You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by ma...@apache.org on 2007/07/19 16:49:04 UTC

svn commit: r557646 - in /myfaces/core/trunk/api/src: main/java/javax/faces/component/_ComponentAttributesMap.java test/java/javax/faces/component/UIComponentAttributesTest.java

Author: matzew
Date: Thu Jul 19 07:49:03 2007
New Revision: 557646

URL: http://svn.apache.org/viewvc?view=rev&rev=557646
Log:
MYFACES-1681

ported original fix down to myfaces 1.1.6-SNAPSHOT

-added fix for the problem
-added test-case for this scenario.

Added:
    myfaces/core/trunk/api/src/test/java/javax/faces/component/UIComponentAttributesTest.java
Modified:
    myfaces/core/trunk/api/src/main/java/javax/faces/component/_ComponentAttributesMap.java

Modified: myfaces/core/trunk/api/src/main/java/javax/faces/component/_ComponentAttributesMap.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/api/src/main/java/javax/faces/component/_ComponentAttributesMap.java?view=diff&rev=557646&r1=557645&r2=557646
==============================================================================
--- myfaces/core/trunk/api/src/main/java/javax/faces/component/_ComponentAttributesMap.java (original)
+++ myfaces/core/trunk/api/src/main/java/javax/faces/component/_ComponentAttributesMap.java Thu Jul 19 07:49:03 2007
@@ -301,9 +301,16 @@
      */
     public Object put(Object key, Object value)
     {
-        checkKeyAndValue(key, value);
+        checkKey(key);
 
         PropertyDescriptor propertyDescriptor = getPropertyDescriptor((String)key);
+
+        if(propertyDescriptor == null)
+        {
+            if(value==null)
+                throw new NullPointerException("value is null for a not available property: " + key);
+        }
+
         if (propertyDescriptor != null)
         {
             if (propertyDescriptor.getReadMethod() != null)
@@ -420,16 +427,6 @@
                     " of component " + _component.getClientId(facesContext) +" to value : "+value+" with type : "+
                     (value==null?"null":value.getClass().getName()), e);
         }
-    }
-
-
-    private void checkKeyAndValue(Object key, Object value)
-    {
-        //http://issues.apache.org/jira/browse/MYFACES-458: obviously, the spec is a little unclear here,
-        // but value == null should be allowed - if there is a TCK-test failing due to this, we should
-        // apply for getting the TCK-test dropped
-        if (value == null) throw new NullPointerException("value");
-        checkKey(key);
     }
 
     private void checkKey(Object key)

Added: myfaces/core/trunk/api/src/test/java/javax/faces/component/UIComponentAttributesTest.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/api/src/test/java/javax/faces/component/UIComponentAttributesTest.java?view=auto&rev=557646
==============================================================================
--- myfaces/core/trunk/api/src/test/java/javax/faces/component/UIComponentAttributesTest.java (added)
+++ myfaces/core/trunk/api/src/test/java/javax/faces/component/UIComponentAttributesTest.java Thu Jul 19 07:49:03 2007
@@ -0,0 +1,40 @@
+package javax.faces.component;
+
+import javax.faces.component.html.HtmlInputText;
+
+import org.apache.shale.test.base.AbstractJsfTestCase;
+
+public class UIComponentAttributesTest extends AbstractJsfTestCase{
+  
+    public UIComponentAttributesTest(String arg0)
+    {
+        super(arg0);
+    }
+
+    private HtmlInputText input;
+    
+    
+    public void setUp() {
+        super.setUp();
+        input = new HtmlInputText();
+        input.setId("testId");
+    }
+
+    public void tearDown() {
+        super.tearDown();
+        input = null;
+    }
+
+    public void testSetNullAttributeOnValidProperty(){
+        input.getAttributes().put("style", null);
+  }
+    public void testSetNullAttributeOnInvalidProperty(){
+        try{
+            input.getAttributes().put("someBogus", null);
+            fail("Should have thrown NullPointerException");
+        }
+        catch(NullPointerException npe){
+            //expected
+        }
+    }
+}
\ No newline at end of file