myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jak...@apache.org
Subject svn commit: r925171 - in /myfaces/core/branches/1.2.x/api/src: main/java/javax/faces/convert/EnumConverter.java test/java/javax/faces/convert/EnumConverterTest.java
Date Fri, 19 Mar 2010 10:34:36 GMT
Author: jakobk
Date: Fri Mar 19 10:34:36 2010
New Revision: 925171

URL: http://svn.apache.org/viewvc?rev=925171&view=rev
Log:
MYFACES-2614 EnumConverter uses toString() instead of name()

Modified:
    myfaces/core/branches/1.2.x/api/src/main/java/javax/faces/convert/EnumConverter.java
    myfaces/core/branches/1.2.x/api/src/test/java/javax/faces/convert/EnumConverterTest.java
  (contents, props changed)

Modified: myfaces/core/branches/1.2.x/api/src/main/java/javax/faces/convert/EnumConverter.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/1.2.x/api/src/main/java/javax/faces/convert/EnumConverter.java?rev=925171&r1=925170&r2=925171&view=diff
==============================================================================
--- myfaces/core/branches/1.2.x/api/src/main/java/javax/faces/convert/EnumConverter.java (original)
+++ myfaces/core/branches/1.2.x/api/src/main/java/javax/faces/convert/EnumConverter.java Fri
Mar 19 10:34:36 2010
@@ -56,8 +56,12 @@ public class EnumConverter implements Co
         if (value == null) return "";
         checkTargetClass(facesContext, uiComponent, value);
         
-        for (Object enumConstant : targetClass.getEnumConstants()) {
-            if (enumConstant == value) return enumConstant.toString();
+        for (Object enumConstant : targetClass.getEnumConstants())
+        {
+            if (enumConstant == value)
+            {
+                return ((Enum<?>) enumConstant).name();
+            }
         }
 
         return value.toString();

Modified: myfaces/core/branches/1.2.x/api/src/test/java/javax/faces/convert/EnumConverterTest.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/1.2.x/api/src/test/java/javax/faces/convert/EnumConverterTest.java?rev=925171&r1=925170&r2=925171&view=diff
==============================================================================
--- myfaces/core/branches/1.2.x/api/src/test/java/javax/faces/convert/EnumConverterTest.java
(original)
+++ myfaces/core/branches/1.2.x/api/src/test/java/javax/faces/convert/EnumConverterTest.java
Fri Mar 19 10:34:36 2010
@@ -31,7 +31,21 @@ import org.apache.shale.test.base.Abstra
  * @version $Revision$ $Date$
  */
 public class EnumConverterTest extends AbstractJsfTestCase {
-    private enum testEnum {ITEM1, ITEM2};
+    
+    private enum testEnum
+    {
+        ITEM1, ITEM2;
+        
+        @Override
+        public String toString()
+        {
+            // overriding toString() to check if converter uses
+            // name() instead of toString() to create the String value.
+            return "enum value";
+        }
+        
+    };
+    
     private EnumConverter converter;
     
     public EnumConverterTest(String name) {
@@ -104,7 +118,7 @@ public class EnumConverterTest extends A
     public void testGetAsString() {
         UIInput input = new UIInput();
         String convertedStr = converter.getAsString(FacesContext.getCurrentInstance(), input,
testEnum.ITEM1);
-        assertEquals(convertedStr, testEnum.ITEM1.toString());
+        assertEquals(convertedStr, testEnum.ITEM1.name());
     }
 
     /**

Propchange: myfaces/core/branches/1.2.x/api/src/test/java/javax/faces/convert/EnumConverterTest.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL



Mime
View raw message