You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lu...@apache.org on 2009/11/24 21:54:15 UTC

svn commit: r883870 - /myfaces/core/trunk/api/src/main/java/javax/faces/component/UISelectMany.java

Author: lu4242
Date: Tue Nov 24 20:54:14 2009
New Revision: 883870

URL: http://svn.apache.org/viewvc?rev=883870&view=rev
Log:
MYFACES-2418 Implement h:selectManyXXX collectionType and hideNoSelectionOption (thanks to Jakob Korherr for this patch)

Modified:
    myfaces/core/trunk/api/src/main/java/javax/faces/component/UISelectMany.java

Modified: myfaces/core/trunk/api/src/main/java/javax/faces/component/UISelectMany.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/api/src/main/java/javax/faces/component/UISelectMany.java?rev=883870&r1=883869&r2=883870&view=diff
==============================================================================
--- myfaces/core/trunk/api/src/main/java/javax/faces/component/UISelectMany.java (original)
+++ myfaces/core/trunk/api/src/main/java/javax/faces/component/UISelectMany.java Tue Nov 24 20:54:14 2009
@@ -183,9 +183,9 @@
             {
                 return compareObjectArrays((Object[]) previous, (Object[]) value);
             }
-            else if (previous instanceof List && value instanceof List)
+            else if (previous instanceof Collection && value instanceof Collection)
             {
-                return compareLists((List<?>) previous, (List<?>) value);
+                return compareCollections((Collection<?>) previous, (Collection<?>) value);
             }
             else if (previous.getClass().isArray() && value.getClass().isArray())
             {
@@ -235,7 +235,7 @@
         return false; // arrays are identical
     }
 
-    private boolean compareLists(List<?> previous, List<?> value)
+    private boolean compareCollections(Collection<?> previous, Collection<?> value)
     {
         int length = value.size();
         if (previous.size() != length)
@@ -245,15 +245,16 @@
         }
 
         boolean[] scoreBoard = new boolean[length];
-        for (int i = 0; i < length; i++)
+        for (Iterator<?> itPrevious = previous.iterator(); itPrevious.hasNext();)
         {
-            Object p = previous.get(i);
+            Object p = itPrevious.next();
             boolean found = false;
-            for (int j = 0; j < length; j++)
+            int j = 0;
+            for (Iterator<?> itValue = value.iterator(); itValue.hasNext(); j++)
             {
+                Object v = itValue.next();
                 if (scoreBoard[j] == false)
                 {
-                    Object v = value.get(j);
                     if ((p == null && v == null) || (p != null && v != null && p.equals(v)))
                     {
                         scoreBoard[j] = true;
@@ -264,11 +265,11 @@
             }
             if (!found)
             {
-                return true; // current element of previous List not found in new List
+                return true; // current element of previous Collection not found in new Collection
             }
         }
 
-        return false; // Lists are identical
+        return false; // Collections are identical
     }
 
     private boolean comparePrimitiveArrays(Object previous, Object value)
@@ -462,9 +463,9 @@
                 Object[] values = (Object[]) convertedValue;
                 return Arrays.asList(values).iterator();
             }
-            else if (convertedValue instanceof List)
+            else if (convertedValue instanceof Collection)
             {
-                List<?> values = (List<?>) convertedValue;
+                Collection<?> values = (Collection<?>) convertedValue;
                 return values.iterator();
             }
             else