MyFaces Core
  1. MyFaces Core
  2. MYFACES-1744

Validation messages is shown for SelectOneMenu in case first child is not SelectItems or SelectItem

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.1.5, 1.2.3
    • Fix Version/s: 1.1.6
    • Component/s: None
    • Labels:
      None
    • Environment:
      Windows XP

      Description

      If SelectOneMenu has child of another type than SelectItems or SelectItem at first place in the children list (e.g. itomahawk jsValueChangeListener), validation of combobox fails with message "Value is not a valid option." Value range is empty in this case because _SelectItemsIterator hasNext() method returns false if first child is not of type SelectItems or SelectItem. It should just skip such children, and should continue looking for values. Right?

      1. _SelectItemsIterator.patch
        0.6 kB
        David Brainard
      2. SelectItemsIterator.patch
        0.6 kB
        David Brainard

        Activity

        Hide
        David Brainard added a comment -

        I have checked with the RI impl they dont have this problem.

        In myfaces if i have any type of component like f:param and f:valuechanelistener etc before f:selectitem or f:selectitems SelectItemsIterator and _SelectItemsIterator does not return correct value for hasNext().

        I have added the following patch to both the classes SelectItemsIterator and _SelectItemsIterator so that they ignore the children which are not UISelectItem and UISelectItems.

        if (_childs.hasNext())
        {
        UIComponent child = (UIComponent) _childs.next();
        while(!(child instanceof UISelectItem)
        && !(child instanceof UISelectItems))

        { child = (UIComponent) _childs.next(); }

        Pls comment if this approach is not suitable.

        i'll add a patch for this soon.

        Show
        David Brainard added a comment - I have checked with the RI impl they dont have this problem. In myfaces if i have any type of component like f:param and f:valuechanelistener etc before f:selectitem or f:selectitems SelectItemsIterator and _SelectItemsIterator does not return correct value for hasNext(). I have added the following patch to both the classes SelectItemsIterator and _SelectItemsIterator so that they ignore the children which are not UISelectItem and UISelectItems. if (_childs.hasNext()) { UIComponent child = (UIComponent) _childs.next(); while(!(child instanceof UISelectItem) && !(child instanceof UISelectItems)) { child = (UIComponent) _childs.next(); } Pls comment if this approach is not suitable. i'll add a patch for this soon.
        Hide
        David Brainard added a comment -

        Patch added.

        Show
        David Brainard added a comment - Patch added.
        Hide
        Galina Gavrilo added a comment -

        Patch suitable, but ,what the procedure to include this patch into official build? Is it possible and how to achieve this?
        Thanks in advance.

        Show
        Galina Gavrilo added a comment - Patch suitable, but ,what the procedure to include this patch into official build? Is it possible and how to achieve this? Thanks in advance.
        Hide
        Leonardo Uribe added a comment -

        After checking this issue the solution proposed is correct, but it should be applied on both shared and core projects, for both 1.1 and 1.2 versions.

        The normal behavior for this iterator should be as proposed on the solution skip elements that does not inherit form UISelectItem or UISelectItems.

        I'll apply this patch soon.

        Show
        Leonardo Uribe added a comment - After checking this issue the solution proposed is correct, but it should be applied on both shared and core projects, for both 1.1 and 1.2 versions. The normal behavior for this iterator should be as proposed on the solution skip elements that does not inherit form UISelectItem or UISelectItems. I'll apply this patch soon.
        Hide
        Leonardo Uribe added a comment -

        The solution proposed has an small bug, so the final solution committed for skip non UISelectItem or UISelectItems is this:

        // 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; }

        }

        Thanks to David Brainard for provide us this patch

        Show
        Leonardo Uribe added a comment - The solution proposed has an small bug, so the final solution committed for skip non UISelectItem or UISelectItems is this: // 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; } } Thanks to David Brainard for provide us this patch

          People

          • Assignee:
            Leonardo Uribe
            Reporter:
            Galina Gavrilo
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development