You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@myfaces.apache.org by "Thomas A. Valletta (JIRA)" <my...@incubator.apache.org> on 2005/10/06 21:56:48 UTC

[jira] Created: (MYFACES-677) HtmlSelectOneMenu conversion error with SelectItemGroup

HtmlSelectOneMenu conversion error with SelectItemGroup
-------------------------------------------------------

         Key: MYFACES-677
         URL: http://issues.apache.org/jira/browse/MYFACES-677
     Project: MyFaces
        Type: Bug
    Versions: 1.1.0    
 Environment: JRE 1.4.2_08 , Tomcat 4.1.27, Firefox
    Reporter: Thomas A. Valletta


While attempting to match the selected SelectItem for an HtmlSelectOneMenu, the matchValue method of SelectItemsUtil calls the getConvertedValue method before checking to see if the SelectItem is really a SelectItemGroup.  This causes conversion errors.  If the SelectItem.getValue() is null (I think that it was before MyFaces1.1) then it would not call the getConvertedValue.  But now you get one ConversionException for every SelectItemGroup that has to be checked before the matching SelectItem is found.

Here is the method stack:
_SelectItemsUtil.matchValue(FacesContext, Object, Iterator, _SelectItemsUtil$_ValueConverter) line: 46
HtmlSelectOneMenu(UISelectOne).validateValue(FacesContext, Object) line: 52
HtmlSelectOneMenu(UIInput).validate(FacesContext) line: 269
HtmlSelectOneMenu(UIInput).processValidators(FacesContext) line: 144

Here is the method in MyFaces 1.1:
    /**
     * @param context the faces context
     * @param value the value to check
     * @param converter 
     * @param iterator contains instances of SelectItem
     * @return if the value of a selectitem is equal to the given value
     */
    public static boolean matchValue(FacesContext context, Object value,
                    Iterator selectItemsIter, _ValueConverter converter)
    {
        while (selectItemsIter.hasNext())
        {
            SelectItem item = (SelectItem) selectItemsIter.next();
            Object itemValue = item.getValue();
            if(converter != null && itemValue instanceof String)
            {
                itemValue = converter.getConvertedValue(context, (String)itemValue);
            }
            if (value.equals(itemValue))
            {
                return true;
            }
            if (item instanceof SelectItemGroup)
            {
                SelectItemGroup itemgroup = (SelectItemGroup) item;
                SelectItem[] selectItems = itemgroup.getSelectItems();
                if (selectItems != null
                                && selectItems.length > 0
                                && matchValue(context, value, Arrays.asList(
                                                selectItems).iterator(), converter))
                {
                    return true;
                }
            }
        }
        return false;
    }

Thanks,
Tom

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Commented: (MYFACES-677) HtmlSelectOneMenu conversion error with SelectItemGroup

Posted by "Mathias Broekelmann (JIRA)" <my...@incubator.apache.org>.
    [ http://issues.apache.org/jira/browse/MYFACES-677?page=comments#action_12331564 ] 

Mathias Broekelmann commented on MYFACES-677:
---------------------------------------------

What do you mean with 'conversion errors'?
Are you using a converter which is not able to convert the string if it is empty?


> HtmlSelectOneMenu conversion error with SelectItemGroup
> -------------------------------------------------------
>
>          Key: MYFACES-677
>          URL: http://issues.apache.org/jira/browse/MYFACES-677
>      Project: MyFaces
>         Type: Bug
>     Versions: 1.1.0
>  Environment: JRE 1.4.2_08 , Tomcat 4.1.27, Firefox
>     Reporter: Thomas A. Valletta

>
> While attempting to match the selected SelectItem for an HtmlSelectOneMenu, the matchValue method of SelectItemsUtil calls the getConvertedValue method before checking to see if the SelectItem is really a SelectItemGroup.  This causes conversion errors.  If the SelectItem.getValue() is null (I think that it was before MyFaces1.1) then it would not call the getConvertedValue.  But now you get one ConversionException for every SelectItemGroup that has to be checked before the matching SelectItem is found.
> Here is the method stack:
> _SelectItemsUtil.matchValue(FacesContext, Object, Iterator, _SelectItemsUtil$_ValueConverter) line: 46
> HtmlSelectOneMenu(UISelectOne).validateValue(FacesContext, Object) line: 52
> HtmlSelectOneMenu(UIInput).validate(FacesContext) line: 269
> HtmlSelectOneMenu(UIInput).processValidators(FacesContext) line: 144
> Here is the method in MyFaces 1.1:
>     /**
>      * @param context the faces context
>      * @param value the value to check
>      * @param converter 
>      * @param iterator contains instances of SelectItem
>      * @return if the value of a selectitem is equal to the given value
>      */
>     public static boolean matchValue(FacesContext context, Object value,
>                     Iterator selectItemsIter, _ValueConverter converter)
>     {
>         while (selectItemsIter.hasNext())
>         {
>             SelectItem item = (SelectItem) selectItemsIter.next();
>             Object itemValue = item.getValue();
>             if(converter != null && itemValue instanceof String)
>             {
>                 itemValue = converter.getConvertedValue(context, (String)itemValue);
>             }
>             if (value.equals(itemValue))
>             {
>                 return true;
>             }
>             if (item instanceof SelectItemGroup)
>             {
>                 SelectItemGroup itemgroup = (SelectItemGroup) item;
>                 SelectItem[] selectItems = itemgroup.getSelectItems();
>                 if (selectItems != null
>                                 && selectItems.length > 0
>                                 && matchValue(context, value, Arrays.asList(
>                                                 selectItems).iterator(), converter))
>                 {
>                     return true;
>                 }
>             }
>         }
>         return false;
>     }
> Thanks,
> Tom

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Commented: (MYFACES-677) HtmlSelectOneMenu conversion error with SelectItemGroup

Posted by "Thomas A. Valletta (JIRA)" <my...@incubator.apache.org>.
    [ http://issues.apache.org/jira/browse/MYFACES-677?page=comments#action_12331532 ] 

Thomas A. Valletta commented on MYFACES-677:
--------------------------------------------

I added

  && ((String)itemValue).length() != 0

to the end of 

   if(converter != null && itemValue instanceof String) 

so that it ended up looking like this:

  if(converter != null && itemValue instanceof String && ((String)itemValue).length() != 0)

and it fixed the issue.


> HtmlSelectOneMenu conversion error with SelectItemGroup
> -------------------------------------------------------
>
>          Key: MYFACES-677
>          URL: http://issues.apache.org/jira/browse/MYFACES-677
>      Project: MyFaces
>         Type: Bug
>     Versions: 1.1.0
>  Environment: JRE 1.4.2_08 , Tomcat 4.1.27, Firefox
>     Reporter: Thomas A. Valletta

>
> While attempting to match the selected SelectItem for an HtmlSelectOneMenu, the matchValue method of SelectItemsUtil calls the getConvertedValue method before checking to see if the SelectItem is really a SelectItemGroup.  This causes conversion errors.  If the SelectItem.getValue() is null (I think that it was before MyFaces1.1) then it would not call the getConvertedValue.  But now you get one ConversionException for every SelectItemGroup that has to be checked before the matching SelectItem is found.
> Here is the method stack:
> _SelectItemsUtil.matchValue(FacesContext, Object, Iterator, _SelectItemsUtil$_ValueConverter) line: 46
> HtmlSelectOneMenu(UISelectOne).validateValue(FacesContext, Object) line: 52
> HtmlSelectOneMenu(UIInput).validate(FacesContext) line: 269
> HtmlSelectOneMenu(UIInput).processValidators(FacesContext) line: 144
> Here is the method in MyFaces 1.1:
>     /**
>      * @param context the faces context
>      * @param value the value to check
>      * @param converter 
>      * @param iterator contains instances of SelectItem
>      * @return if the value of a selectitem is equal to the given value
>      */
>     public static boolean matchValue(FacesContext context, Object value,
>                     Iterator selectItemsIter, _ValueConverter converter)
>     {
>         while (selectItemsIter.hasNext())
>         {
>             SelectItem item = (SelectItem) selectItemsIter.next();
>             Object itemValue = item.getValue();
>             if(converter != null && itemValue instanceof String)
>             {
>                 itemValue = converter.getConvertedValue(context, (String)itemValue);
>             }
>             if (value.equals(itemValue))
>             {
>                 return true;
>             }
>             if (item instanceof SelectItemGroup)
>             {
>                 SelectItemGroup itemgroup = (SelectItemGroup) item;
>                 SelectItem[] selectItems = itemgroup.getSelectItems();
>                 if (selectItems != null
>                                 && selectItems.length > 0
>                                 && matchValue(context, value, Arrays.asList(
>                                                 selectItems).iterator(), converter))
>                 {
>                     return true;
>                 }
>             }
>         }
>         return false;
>     }
> Thanks,
> Tom

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Commented: (MYFACES-677) HtmlSelectOneMenu conversion error with SelectItemGroup

Posted by "Thomas A. Valletta (JIRA)" <my...@incubator.apache.org>.
    [ http://issues.apache.org/jira/browse/MYFACES-677?page=comments#action_12331586 ] 

Thomas A. Valletta commented on MYFACES-677:
--------------------------------------------

Yes.  I apologise for the poor explanation.  This would only occur if you have a converter on the component and are using SelectItemGroups.  The way that the code is currently, the "item" is a SelectItemGroup.  When item.getValue() is called an empty string is returned (that might be the bug).  Because there is a converter and the empty string is an instance of String, the converter is run against the SelectItemGroup.  That is where you will likely have conversion errors.  It is likely that any converter that will be applied to the component will not be expecting a SelectItemGroup.  Instead it will be expecting the object returned from item.getValue() where item is a SelectItem.

Hope this clarifies.
Tom

> HtmlSelectOneMenu conversion error with SelectItemGroup
> -------------------------------------------------------
>
>          Key: MYFACES-677
>          URL: http://issues.apache.org/jira/browse/MYFACES-677
>      Project: MyFaces
>         Type: Bug
>     Versions: 1.1.0
>  Environment: JRE 1.4.2_08 , Tomcat 4.1.27, Firefox
>     Reporter: Thomas A. Valletta
>     Assignee: Mathias Broekelmann

>
> While attempting to match the selected SelectItem for an HtmlSelectOneMenu, the matchValue method of SelectItemsUtil calls the getConvertedValue method before checking to see if the SelectItem is really a SelectItemGroup.  This causes conversion errors.  If the SelectItem.getValue() is null (I think that it was before MyFaces1.1) then it would not call the getConvertedValue.  But now you get one ConversionException for every SelectItemGroup that has to be checked before the matching SelectItem is found.
> Here is the method stack:
> _SelectItemsUtil.matchValue(FacesContext, Object, Iterator, _SelectItemsUtil$_ValueConverter) line: 46
> HtmlSelectOneMenu(UISelectOne).validateValue(FacesContext, Object) line: 52
> HtmlSelectOneMenu(UIInput).validate(FacesContext) line: 269
> HtmlSelectOneMenu(UIInput).processValidators(FacesContext) line: 144
> Here is the method in MyFaces 1.1:
>     /**
>      * @param context the faces context
>      * @param value the value to check
>      * @param converter 
>      * @param iterator contains instances of SelectItem
>      * @return if the value of a selectitem is equal to the given value
>      */
>     public static boolean matchValue(FacesContext context, Object value,
>                     Iterator selectItemsIter, _ValueConverter converter)
>     {
>         while (selectItemsIter.hasNext())
>         {
>             SelectItem item = (SelectItem) selectItemsIter.next();
>             Object itemValue = item.getValue();
>             if(converter != null && itemValue instanceof String)
>             {
>                 itemValue = converter.getConvertedValue(context, (String)itemValue);
>             }
>             if (value.equals(itemValue))
>             {
>                 return true;
>             }
>             if (item instanceof SelectItemGroup)
>             {
>                 SelectItemGroup itemgroup = (SelectItemGroup) item;
>                 SelectItem[] selectItems = itemgroup.getSelectItems();
>                 if (selectItems != null
>                                 && selectItems.length > 0
>                                 && matchValue(context, value, Arrays.asList(
>                                                 selectItems).iterator(), converter))
>                 {
>                     return true;
>                 }
>             }
>         }
>         return false;
>     }
> Thanks,
> Tom

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Commented: (MYFACES-677) HtmlSelectOneMenu conversion error with SelectItemGroup

Posted by "Mathias Broekelmann (JIRA)" <my...@incubator.apache.org>.
    [ http://issues.apache.org/jira/browse/MYFACES-677?page=comments#action_12331594 ] 

Mathias Broekelmann commented on MYFACES-677:
---------------------------------------------

IMO it´s a problem with the converter. The converter could handle empty strings by simply returning null.

If someone uses a complex object for the value and an empty string to indicate a null value he wouldn´t be able to use that if we don´t pass the empty string to the converter.

> HtmlSelectOneMenu conversion error with SelectItemGroup
> -------------------------------------------------------
>
>          Key: MYFACES-677
>          URL: http://issues.apache.org/jira/browse/MYFACES-677
>      Project: MyFaces
>         Type: Bug
>     Versions: 1.1.0
>  Environment: JRE 1.4.2_08 , Tomcat 4.1.27, Firefox
>     Reporter: Thomas A. Valletta
>     Assignee: Mathias Broekelmann

>
> While attempting to match the selected SelectItem for an HtmlSelectOneMenu, the matchValue method of SelectItemsUtil calls the getConvertedValue method before checking to see if the SelectItem is really a SelectItemGroup.  This causes conversion errors.  If the SelectItem.getValue() is null (I think that it was before MyFaces1.1) then it would not call the getConvertedValue.  But now you get one ConversionException for every SelectItemGroup that has to be checked before the matching SelectItem is found.
> Here is the method stack:
> _SelectItemsUtil.matchValue(FacesContext, Object, Iterator, _SelectItemsUtil$_ValueConverter) line: 46
> HtmlSelectOneMenu(UISelectOne).validateValue(FacesContext, Object) line: 52
> HtmlSelectOneMenu(UIInput).validate(FacesContext) line: 269
> HtmlSelectOneMenu(UIInput).processValidators(FacesContext) line: 144
> Here is the method in MyFaces 1.1:
>     /**
>      * @param context the faces context
>      * @param value the value to check
>      * @param converter 
>      * @param iterator contains instances of SelectItem
>      * @return if the value of a selectitem is equal to the given value
>      */
>     public static boolean matchValue(FacesContext context, Object value,
>                     Iterator selectItemsIter, _ValueConverter converter)
>     {
>         while (selectItemsIter.hasNext())
>         {
>             SelectItem item = (SelectItem) selectItemsIter.next();
>             Object itemValue = item.getValue();
>             if(converter != null && itemValue instanceof String)
>             {
>                 itemValue = converter.getConvertedValue(context, (String)itemValue);
>             }
>             if (value.equals(itemValue))
>             {
>                 return true;
>             }
>             if (item instanceof SelectItemGroup)
>             {
>                 SelectItemGroup itemgroup = (SelectItemGroup) item;
>                 SelectItem[] selectItems = itemgroup.getSelectItems();
>                 if (selectItems != null
>                                 && selectItems.length > 0
>                                 && matchValue(context, value, Arrays.asList(
>                                                 selectItems).iterator(), converter))
>                 {
>                     return true;
>                 }
>             }
>         }
>         return false;
>     }
> Thanks,
> Tom

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Closed: (MYFACES-677) HtmlSelectOneMenu conversion error with SelectItemGroup

Posted by "Mathias Broekelmann (JIRA)" <my...@incubator.apache.org>.
     [ http://issues.apache.org/jira/browse/MYFACES-677?page=all ]
     
Mathias Broekelmann closed MYFACES-677:
---------------------------------------

    Fix Version: Nightly
                 1.1.1
     Resolution: Fixed

fixed in trunk and branch for 1.1.1 release

> HtmlSelectOneMenu conversion error with SelectItemGroup
> -------------------------------------------------------
>
>          Key: MYFACES-677
>          URL: http://issues.apache.org/jira/browse/MYFACES-677
>      Project: MyFaces
>         Type: Bug
>     Versions: 1.1.0
>  Environment: JRE 1.4.2_08 , Tomcat 4.1.27, Firefox
>     Reporter: Thomas A. Valletta
>     Assignee: Mathias Broekelmann
>      Fix For: 1.1.1, Nightly

>
> While attempting to match the selected SelectItem for an HtmlSelectOneMenu, the matchValue method of SelectItemsUtil calls the getConvertedValue method before checking to see if the SelectItem is really a SelectItemGroup.  This causes conversion errors.  If the SelectItem.getValue() is null (I think that it was before MyFaces1.1) then it would not call the getConvertedValue.  But now you get one ConversionException for every SelectItemGroup that has to be checked before the matching SelectItem is found.
> Here is the method stack:
> _SelectItemsUtil.matchValue(FacesContext, Object, Iterator, _SelectItemsUtil$_ValueConverter) line: 46
> HtmlSelectOneMenu(UISelectOne).validateValue(FacesContext, Object) line: 52
> HtmlSelectOneMenu(UIInput).validate(FacesContext) line: 269
> HtmlSelectOneMenu(UIInput).processValidators(FacesContext) line: 144
> Here is the method in MyFaces 1.1:
>     /**
>      * @param context the faces context
>      * @param value the value to check
>      * @param converter 
>      * @param iterator contains instances of SelectItem
>      * @return if the value of a selectitem is equal to the given value
>      */
>     public static boolean matchValue(FacesContext context, Object value,
>                     Iterator selectItemsIter, _ValueConverter converter)
>     {
>         while (selectItemsIter.hasNext())
>         {
>             SelectItem item = (SelectItem) selectItemsIter.next();
>             Object itemValue = item.getValue();
>             if(converter != null && itemValue instanceof String)
>             {
>                 itemValue = converter.getConvertedValue(context, (String)itemValue);
>             }
>             if (value.equals(itemValue))
>             {
>                 return true;
>             }
>             if (item instanceof SelectItemGroup)
>             {
>                 SelectItemGroup itemgroup = (SelectItemGroup) item;
>                 SelectItem[] selectItems = itemgroup.getSelectItems();
>                 if (selectItems != null
>                                 && selectItems.length > 0
>                                 && matchValue(context, value, Arrays.asList(
>                                                 selectItems).iterator(), converter))
>                 {
>                     return true;
>                 }
>             }
>         }
>         return false;
>     }
> Thanks,
> Tom

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Commented: (MYFACES-677) HtmlSelectOneMenu conversion error with SelectItemGroup

Posted by "Mathias Broekelmann (JIRA)" <my...@incubator.apache.org>.
    [ http://issues.apache.org/jira/browse/MYFACES-677?page=comments#action_12331598 ] 

Mathias Broekelmann commented on MYFACES-677:
---------------------------------------------

that´s much better. The only thing is that I´m not sure if a SelectItemGroup is not selectable in every case. 

> HtmlSelectOneMenu conversion error with SelectItemGroup
> -------------------------------------------------------
>
>          Key: MYFACES-677
>          URL: http://issues.apache.org/jira/browse/MYFACES-677
>      Project: MyFaces
>         Type: Bug
>     Versions: 1.1.0
>  Environment: JRE 1.4.2_08 , Tomcat 4.1.27, Firefox
>     Reporter: Thomas A. Valletta
>     Assignee: Mathias Broekelmann

>
> While attempting to match the selected SelectItem for an HtmlSelectOneMenu, the matchValue method of SelectItemsUtil calls the getConvertedValue method before checking to see if the SelectItem is really a SelectItemGroup.  This causes conversion errors.  If the SelectItem.getValue() is null (I think that it was before MyFaces1.1) then it would not call the getConvertedValue.  But now you get one ConversionException for every SelectItemGroup that has to be checked before the matching SelectItem is found.
> Here is the method stack:
> _SelectItemsUtil.matchValue(FacesContext, Object, Iterator, _SelectItemsUtil$_ValueConverter) line: 46
> HtmlSelectOneMenu(UISelectOne).validateValue(FacesContext, Object) line: 52
> HtmlSelectOneMenu(UIInput).validate(FacesContext) line: 269
> HtmlSelectOneMenu(UIInput).processValidators(FacesContext) line: 144
> Here is the method in MyFaces 1.1:
>     /**
>      * @param context the faces context
>      * @param value the value to check
>      * @param converter 
>      * @param iterator contains instances of SelectItem
>      * @return if the value of a selectitem is equal to the given value
>      */
>     public static boolean matchValue(FacesContext context, Object value,
>                     Iterator selectItemsIter, _ValueConverter converter)
>     {
>         while (selectItemsIter.hasNext())
>         {
>             SelectItem item = (SelectItem) selectItemsIter.next();
>             Object itemValue = item.getValue();
>             if(converter != null && itemValue instanceof String)
>             {
>                 itemValue = converter.getConvertedValue(context, (String)itemValue);
>             }
>             if (value.equals(itemValue))
>             {
>                 return true;
>             }
>             if (item instanceof SelectItemGroup)
>             {
>                 SelectItemGroup itemgroup = (SelectItemGroup) item;
>                 SelectItem[] selectItems = itemgroup.getSelectItems();
>                 if (selectItems != null
>                                 && selectItems.length > 0
>                                 && matchValue(context, value, Arrays.asList(
>                                                 selectItems).iterator(), converter))
>                 {
>                     return true;
>                 }
>             }
>         }
>         return false;
>     }
> Thanks,
> Tom

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Commented: (MYFACES-677) HtmlSelectOneMenu conversion error with SelectItemGroup

Posted by "Thomas A. Valletta (JIRA)" <my...@incubator.apache.org>.
    [ http://issues.apache.org/jira/browse/MYFACES-677?page=comments#action_12331603 ] 

Thomas A. Valletta commented on MYFACES-677:
--------------------------------------------

I don't think that there is anything in JSF that keeps you from putting a value into a SelectitemGroup, but I know that the optgroup HTML element has no attribute for a value.  The HTML spec does not allow for an optgroup to be selected either.  So if a SelectItemGroup can be selected, it would be for rederkits that are not HTML.  

Either way, it wouldn't matter if the SelectItemGroup is selected, the conversion should still be skipped.  

Thanks for your help on this.
Tom

> HtmlSelectOneMenu conversion error with SelectItemGroup
> -------------------------------------------------------
>
>          Key: MYFACES-677
>          URL: http://issues.apache.org/jira/browse/MYFACES-677
>      Project: MyFaces
>         Type: Bug
>     Versions: 1.1.0
>  Environment: JRE 1.4.2_08 , Tomcat 4.1.27, Firefox
>     Reporter: Thomas A. Valletta
>     Assignee: Mathias Broekelmann

>
> While attempting to match the selected SelectItem for an HtmlSelectOneMenu, the matchValue method of SelectItemsUtil calls the getConvertedValue method before checking to see if the SelectItem is really a SelectItemGroup.  This causes conversion errors.  If the SelectItem.getValue() is null (I think that it was before MyFaces1.1) then it would not call the getConvertedValue.  But now you get one ConversionException for every SelectItemGroup that has to be checked before the matching SelectItem is found.
> Here is the method stack:
> _SelectItemsUtil.matchValue(FacesContext, Object, Iterator, _SelectItemsUtil$_ValueConverter) line: 46
> HtmlSelectOneMenu(UISelectOne).validateValue(FacesContext, Object) line: 52
> HtmlSelectOneMenu(UIInput).validate(FacesContext) line: 269
> HtmlSelectOneMenu(UIInput).processValidators(FacesContext) line: 144
> Here is the method in MyFaces 1.1:
>     /**
>      * @param context the faces context
>      * @param value the value to check
>      * @param converter 
>      * @param iterator contains instances of SelectItem
>      * @return if the value of a selectitem is equal to the given value
>      */
>     public static boolean matchValue(FacesContext context, Object value,
>                     Iterator selectItemsIter, _ValueConverter converter)
>     {
>         while (selectItemsIter.hasNext())
>         {
>             SelectItem item = (SelectItem) selectItemsIter.next();
>             Object itemValue = item.getValue();
>             if(converter != null && itemValue instanceof String)
>             {
>                 itemValue = converter.getConvertedValue(context, (String)itemValue);
>             }
>             if (value.equals(itemValue))
>             {
>                 return true;
>             }
>             if (item instanceof SelectItemGroup)
>             {
>                 SelectItemGroup itemgroup = (SelectItemGroup) item;
>                 SelectItem[] selectItems = itemgroup.getSelectItems();
>                 if (selectItems != null
>                                 && selectItems.length > 0
>                                 && matchValue(context, value, Arrays.asList(
>                                                 selectItems).iterator(), converter))
>                 {
>                     return true;
>                 }
>             }
>         }
>         return false;
>     }
> Thanks,
> Tom

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Commented: (MYFACES-677) HtmlSelectOneMenu conversion error with SelectItemGroup

Posted by "Thomas A. Valletta (JIRA)" <my...@incubator.apache.org>.
    [ http://issues.apache.org/jira/browse/MYFACES-677?page=comments#action_12331597 ] 

Thomas A. Valletta commented on MYFACES-677:
--------------------------------------------

OK.  I can see where it would be useful for converters to handle empty strings.  To require that every converter handle empty strings is another.  But I will concede this point.

However, I still see an issue with calling the converter on the SelectItemGroup.  Even if your converter does handle an empty string, it should not be called to convert a SelectItemGroup.  

So instead of changeing the code to this (previously proposed):

      if(converter != null && itemValue instanceof String && ((String)itemValue).length() != 0) 

Change it to (something like this):

      if(converter != null && itemValue instanceof String && !(item instanceof SelectItemGroup)) 

> HtmlSelectOneMenu conversion error with SelectItemGroup
> -------------------------------------------------------
>
>          Key: MYFACES-677
>          URL: http://issues.apache.org/jira/browse/MYFACES-677
>      Project: MyFaces
>         Type: Bug
>     Versions: 1.1.0
>  Environment: JRE 1.4.2_08 , Tomcat 4.1.27, Firefox
>     Reporter: Thomas A. Valletta
>     Assignee: Mathias Broekelmann

>
> While attempting to match the selected SelectItem for an HtmlSelectOneMenu, the matchValue method of SelectItemsUtil calls the getConvertedValue method before checking to see if the SelectItem is really a SelectItemGroup.  This causes conversion errors.  If the SelectItem.getValue() is null (I think that it was before MyFaces1.1) then it would not call the getConvertedValue.  But now you get one ConversionException for every SelectItemGroup that has to be checked before the matching SelectItem is found.
> Here is the method stack:
> _SelectItemsUtil.matchValue(FacesContext, Object, Iterator, _SelectItemsUtil$_ValueConverter) line: 46
> HtmlSelectOneMenu(UISelectOne).validateValue(FacesContext, Object) line: 52
> HtmlSelectOneMenu(UIInput).validate(FacesContext) line: 269
> HtmlSelectOneMenu(UIInput).processValidators(FacesContext) line: 144
> Here is the method in MyFaces 1.1:
>     /**
>      * @param context the faces context
>      * @param value the value to check
>      * @param converter 
>      * @param iterator contains instances of SelectItem
>      * @return if the value of a selectitem is equal to the given value
>      */
>     public static boolean matchValue(FacesContext context, Object value,
>                     Iterator selectItemsIter, _ValueConverter converter)
>     {
>         while (selectItemsIter.hasNext())
>         {
>             SelectItem item = (SelectItem) selectItemsIter.next();
>             Object itemValue = item.getValue();
>             if(converter != null && itemValue instanceof String)
>             {
>                 itemValue = converter.getConvertedValue(context, (String)itemValue);
>             }
>             if (value.equals(itemValue))
>             {
>                 return true;
>             }
>             if (item instanceof SelectItemGroup)
>             {
>                 SelectItemGroup itemgroup = (SelectItemGroup) item;
>                 SelectItem[] selectItems = itemgroup.getSelectItems();
>                 if (selectItems != null
>                                 && selectItems.length > 0
>                                 && matchValue(context, value, Arrays.asList(
>                                                 selectItems).iterator(), converter))
>                 {
>                     return true;
>                 }
>             }
>         }
>         return false;
>     }
> Thanks,
> Tom

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira