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 2008/08/04 22:23:04 UTC

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

Author: lu4242
Date: Mon Aug  4 13:23:04 2008
New Revision: 682491

URL: http://svn.apache.org/viewvc?rev=682491&view=rev
Log:
MYFACES-1744 Validation messages is shown for SelectOneMenu in case first child is not SelectItems or SelectItem (skip nested components that does not inherit form UISelectItem or UISelectItems)

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

Modified: myfaces/core/trunk/api/src/main/java/javax/faces/component/_SelectItemsIterator.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/api/src/main/java/javax/faces/component/_SelectItemsIterator.java?rev=682491&r1=682490&r2=682491&view=diff
==============================================================================
--- myfaces/core/trunk/api/src/main/java/javax/faces/component/_SelectItemsIterator.java (original)
+++ myfaces/core/trunk/api/src/main/java/javax/faces/component/_SelectItemsIterator.java Mon Aug  4 13:23:04 2008
@@ -57,6 +57,28 @@
         if (_childs.hasNext())
         {
             UIComponent child = (UIComponent) _childs.next();
+            // When there is other components nested that does
+            // not extends from UISelectItem or UISelectItems
+            // the behavior for this iterator is just skip this
+            // element(s) until an element that extends from these
+            // classes are found. If there is no more elements
+            // that conform this condition, just return false.
+            while (!(child instanceof UISelectItem)
+                    && !(child instanceof UISelectItems))
+            {
+                //Try to skip it
+                if (_childs.hasNext())
+                {
+                    //Skip and do the same check
+                    child = (UIComponent) _childs.next();
+                }
+                else
+                {
+                    //End loop, so the final result is return false,
+                    //since there are no more components to iterate.
+                    return false;
+                }
+            }
             if (child instanceof UISelectItem)
             {
                 UISelectItem uiSelectItem = (UISelectItem) child;
@@ -143,11 +165,6 @@
                                         .getName()));
                 }
             }
-            else
-            {
-                //todo: may other objects than selectItems be nested or not?
-                //log.error("Invalid component : " + getPathToComponent(child) + " : must be UISelectItem or UISelectItems, is of type : "+((child==null)?"null":child.getClass().getName()));
-            }
         }
         return false;
     }