You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@myfaces.apache.org by "Alois Vitasek (JIRA)" <de...@myfaces.apache.org> on 2006/08/10 16:55:14 UTC

[jira] Created: (MYFACES-1382) SelectItem getValue type problem

SelectItem getValue type problem
--------------------------------

                 Key: MYFACES-1382
                 URL: http://issues.apache.org/jira/browse/MYFACES-1382
             Project: MyFaces Core
          Issue Type: Bug
    Affects Versions: 1.1.3
         Environment: Tomcat 5.0.28
            Reporter: Alois Vitasek
            Priority: Minor


Sorry for my english please.

I am using list of SelectItem objects to fill data in listbox. Listbox is using
an converor.

SelectItem object has method getValue, which returns a type Object.
In my case is type of the value property an Integer.

In class 

  javax.faces.component._SelectItemsUtil

is method matchValue which is testing if value of the componet exists
in set of values in the listbox. Listbox contais "raw values", value in listbox
is converted.

The code is

                Object itemValue = item.getValue();
                if(converter != null && itemValue instanceof String)
                {
                    itemValue = converter.getConvertedValue(context, (String)itemValue);
                }
                if (value==itemValue || value.equals(itemValue))
                ....


If in listbox are values not in type String (for example Integer), convertor is not
invoked and following test will fails and application will end with validation error exception.

This problem can be solved if only Strings  are used as value in listbox which are using
convertors. (trap ?)

Or change this code to something like this:

                Object itemValue = item.getValue();
                if(converter != null)
                {
                    itemValue = converter.getConvertedValue(context, itemValue.toString());
                }

Or not allow to use no String value in a SelectItem object.

Alois Vitasek


-- 
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] Updated: (MYFACES-1382) SelectItem getValue type problem

Posted by "Zdenek Sochor (JIRA)" <de...@myfaces.apache.org>.
     [ http://issues.apache.org/jira/browse/MYFACES-1382?page=all ]

Zdenek Sochor updated MYFACES-1382:
-----------------------------------

    Status: Patch Available  (was: Open)

> SelectItem getValue type problem
> --------------------------------
>
>                 Key: MYFACES-1382
>                 URL: http://issues.apache.org/jira/browse/MYFACES-1382
>             Project: MyFaces Core
>          Issue Type: Bug
>    Affects Versions: 1.1.3
>         Environment: Tomcat 5.0.28
>            Reporter: Alois Vitasek
>            Priority: Minor
>         Attachments: _SelectItemsUtil.java.patch
>
>
> Sorry for my english please.
> I am using list of SelectItem objects to fill data in listbox. Listbox is using
> an converor.
> SelectItem object has method getValue, which returns a type Object.
> In my case is type of the value property an Integer.
> In class 
>   javax.faces.component._SelectItemsUtil
> is method matchValue which is testing if value of the componet exists
> in set of values in the listbox. Listbox contais "raw values", value in listbox
> is converted.
> The code is
>                 Object itemValue = item.getValue();
>                 if(converter != null && itemValue instanceof String)
>                 {
>                     itemValue = converter.getConvertedValue(context, (String)itemValue);
>                 }
>                 if (value==itemValue || value.equals(itemValue))
>                 ....
> If in listbox are values not in type String (for example Integer), convertor is not
> invoked and following test will fails and application will end with validation error exception.
> This problem can be solved if only Strings  are used as value in listbox which are using
> convertors. (trap ?)
> Or change this code to something like this:
>                 Object itemValue = item.getValue();
>                 if(converter != null)
>                 {
>                     itemValue = converter.getConvertedValue(context, itemValue.toString());
>                 }
> Or not allow to use no String value in a SelectItem object.
> Alois Vitasek

-- 
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