You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@myfaces.apache.org by "Alexey Maslov (JIRA)" <de...@myfaces.apache.org> on 2006/06/07 19:12:29 UTC

[jira] Created: (MYFACES-1328) UISelectOne and UISelectMany fail with custom converter that returns java.lang.String from getAsObject() method.

UISelectOne and UISelectMany fail with custom converter that returns java.lang.String from getAsObject() method.
----------------------------------------------------------------------------------------------------------------

         Key: MYFACES-1328
         URL: http://issues.apache.org/jira/browse/MYFACES-1328
     Project: MyFaces Core
        Type: Bug

    Versions: 1.1.4-SNAPSHOT    
    Reporter: Alexey Maslov


The problem seems to be in javax.faces.component._SelectItemsUtil.matchValue(FacesContext context, Object value, Iterator selectItemsIter, _ValueConverter converter) method.

Line 63-72:
                Object itemValue = item.getValue();
                if(converter != null && itemValue instanceof String)
                {
                    itemValue = converter.getConvertedValue(context, (String)itemValue);
                }
                if (value==itemValue || value.equals(itemValue))
                {
                    return true;
                }

If item's value is java.lang.String then this code does duplicate conversion making matchValue() return false and subsequently resulting in error in calling method (validateValue() in javax.faces.component.UISelectOne and javax.faces.component.UISelectMany).

-- 
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] Resolved: (MYFACES-1328) UISelectOne and UISelectMany fail with custom converter that returns java.lang.String from getAsObject() method.

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

Martin Marinschek resolved MYFACES-1328.
----------------------------------------

    Fix Version/s: 1.1.5-SNAPSHOT
       Resolution: Fixed
         Assignee: Martin Marinschek

You're absolutely right, Nikolay. Thanks for tracking this down.

regards,

Martin

> UISelectOne and UISelectMany fail with custom converter that returns java.lang.String from getAsObject() method.
> ----------------------------------------------------------------------------------------------------------------
>
>                 Key: MYFACES-1328
>                 URL: http://issues.apache.org/jira/browse/MYFACES-1328
>             Project: MyFaces Core
>          Issue Type: Bug
>    Affects Versions: 1.1.4-SNAPSHOT
>            Reporter: Alexey Maslov
>         Assigned To: Martin Marinschek
>             Fix For: 1.1.5-SNAPSHOT
>
>         Attachments: reproducer.zip
>
>
> The problem seems to be in javax.faces.component._SelectItemsUtil.matchValue(FacesContext context, Object value, Iterator selectItemsIter, _ValueConverter converter) method.
> Line 63-72:
>                 Object itemValue = item.getValue();
>                 if(converter != null && itemValue instanceof String)
>                 {
>                     itemValue = converter.getConvertedValue(context, (String)itemValue);
>                 }
>                 if (value==itemValue || value.equals(itemValue))
>                 {
>                     return true;
>                 }
> If item's value is java.lang.String then this code does duplicate conversion making matchValue() return false and subsequently resulting in error in calling method (validateValue() in javax.faces.component.UISelectOne and javax.faces.component.UISelectMany).

-- 
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] Resolved: (MYFACES-1328) UISelectOne and UISelectMany fail with custom converter that returns java.lang.String from getAsObject() method.

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

Grant Smith resolved MYFACES-1328.
----------------------------------

    Resolution: Fixed

It turns out my application was missing <h:messages>, so of course, no validation message was reaching me. I'll close this, although I'm sure we're going to have a lot of users that got spoiled by having the convenient conversion. Still, we must follow the behaviour of the RI...

> UISelectOne and UISelectMany fail with custom converter that returns java.lang.String from getAsObject() method.
> ----------------------------------------------------------------------------------------------------------------
>
>                 Key: MYFACES-1328
>                 URL: http://issues.apache.org/jira/browse/MYFACES-1328
>             Project: MyFaces Core
>          Issue Type: Bug
>    Affects Versions: 1.1.4-SNAPSHOT
>            Reporter: Alexey Maslov
>         Assigned To: Martin Marinschek
>             Fix For: 1.1.5-SNAPSHOT
>
>         Attachments: reproducer.zip
>
>
> The problem seems to be in javax.faces.component._SelectItemsUtil.matchValue(FacesContext context, Object value, Iterator selectItemsIter, _ValueConverter converter) method.
> Line 63-72:
>                 Object itemValue = item.getValue();
>                 if(converter != null && itemValue instanceof String)
>                 {
>                     itemValue = converter.getConvertedValue(context, (String)itemValue);
>                 }
>                 if (value==itemValue || value.equals(itemValue))
>                 {
>                     return true;
>                 }
> If item's value is java.lang.String then this code does duplicate conversion making matchValue() return false and subsequently resulting in error in calling method (validateValue() in javax.faces.component.UISelectOne and javax.faces.component.UISelectMany).

-- 
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] Reopened: (MYFACES-1328) UISelectOne and UISelectMany fail with custom converter that returns java.lang.String from getAsObject() method.

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

Martin Marinschek reopened MYFACES-1328:
----------------------------------------

             
Grant has had problems with this - conversion errors which are not logged and stop his application dead in conversion and validation.

regards,

Martin

> UISelectOne and UISelectMany fail with custom converter that returns java.lang.String from getAsObject() method.
> ----------------------------------------------------------------------------------------------------------------
>
>                 Key: MYFACES-1328
>                 URL: http://issues.apache.org/jira/browse/MYFACES-1328
>             Project: MyFaces Core
>          Issue Type: Bug
>    Affects Versions: 1.1.4-SNAPSHOT
>            Reporter: Alexey Maslov
>         Assigned To: Martin Marinschek
>             Fix For: 1.1.5-SNAPSHOT
>
>         Attachments: reproducer.zip
>
>
> The problem seems to be in javax.faces.component._SelectItemsUtil.matchValue(FacesContext context, Object value, Iterator selectItemsIter, _ValueConverter converter) method.
> Line 63-72:
>                 Object itemValue = item.getValue();
>                 if(converter != null && itemValue instanceof String)
>                 {
>                     itemValue = converter.getConvertedValue(context, (String)itemValue);
>                 }
>                 if (value==itemValue || value.equals(itemValue))
>                 {
>                     return true;
>                 }
> If item's value is java.lang.String then this code does duplicate conversion making matchValue() return false and subsequently resulting in error in calling method (validateValue() in javax.faces.component.UISelectOne and javax.faces.component.UISelectMany).

-- 
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-1328) UISelectOne and UISelectMany fail with custom converter that returns java.lang.String from getAsObject() method.

Posted by "Daniel Campagnoli (JIRA)" <de...@myfaces.apache.org>.
    [ http://issues.apache.org/jira/browse/MYFACES-1328?page=comments#action_12447399 ] 
            
Daniel Campagnoli commented on MYFACES-1328:
--------------------------------------------

We are one of the many spoilt users that rely on the convenient conversion! We would be dissapointed to see this behaviour go as convenience is a good thing. We had just updated to the latest nightly build and it's broken our application.

I've had a look at the _SelectItemsUtil class, and it appears the problem could be solved by re-ordering the extra conversion to be after the initial equals check, which wouldn't break with custom converters that return String's. So the code snipped in this issues description would be replaced with: 

                Object itemValue = item.getValue(); 
                if (value==itemValue || value.equals(itemValue)) 
                { 
                    return true; 
                } 
               if(convenientConversion) // optional if statement so the default behaviour could match the RI
                {
                      if(converter != null && itemValue instanceof String) 
                      { 
                          itemValue = converter.getConvertedValue(context, (String)itemValue); 
                           if (value==itemValue || value.equals(itemValue)) 
                           { 
                                return true; 
                           } 
                      }    
                 }

The faces context and converter arguments would have to be added back to the matchValue() method and creation of the _ValueConverter in UISelectMany added back in.

Dan

> UISelectOne and UISelectMany fail with custom converter that returns java.lang.String from getAsObject() method.
> ----------------------------------------------------------------------------------------------------------------
>
>                 Key: MYFACES-1328
>                 URL: http://issues.apache.org/jira/browse/MYFACES-1328
>             Project: MyFaces Core
>          Issue Type: Bug
>    Affects Versions: 1.1.4-SNAPSHOT
>            Reporter: Alexey Maslov
>         Assigned To: Martin Marinschek
>             Fix For: 1.1.5-SNAPSHOT
>
>         Attachments: reproducer.zip
>
>
> The problem seems to be in javax.faces.component._SelectItemsUtil.matchValue(FacesContext context, Object value, Iterator selectItemsIter, _ValueConverter converter) method.
> Line 63-72:
>                 Object itemValue = item.getValue();
>                 if(converter != null && itemValue instanceof String)
>                 {
>                     itemValue = converter.getConvertedValue(context, (String)itemValue);
>                 }
>                 if (value==itemValue || value.equals(itemValue))
>                 {
>                     return true;
>                 }
> If item's value is java.lang.String then this code does duplicate conversion making matchValue() return false and subsequently resulting in error in calling method (validateValue() in javax.faces.component.UISelectOne and javax.faces.component.UISelectMany).

-- 
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-1328) UISelectOne and UISelectMany fail with custom converter that returns java.lang.String from getAsObject() method.

Posted by "Paul Devine (JIRA)" <de...@myfaces.apache.org>.
    [ https://issues.apache.org/jira/browse/MYFACES-1328?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12492118 ] 

Paul Devine commented on MYFACES-1328:
--------------------------------------

This comment is not intended as a bug report of any kind, but might other users with a possible 1.1.5 upgrade problem. In upgrading to 1.1.5 the faces validation phase was causing the lifecycle to exit on some of our pages that were working just fine in 1.1.3.   It turns out we were relying on the conversion discussed above, because our pages used selectOneRadio's in a manner illustrated below :

<h:selectOneRadio value="#{myBean.someBooleanProperty}" converter="javax.faces.Boolean"  ...>
  <f:selectItem itemValue="true" itemLabel="Yes" />
  <f:selectItem itemValue="false" itemLabel="No"/>
</h:selectOneRadio>

The _SelectItemsUtil.matchValue method in myfaces prior to 1.1.5 would handle this by converting the "true" and "false" on the fly to Boolean.TRUE and Boolean.FALSE because we specified the BooleanConverter. The validation phase would be ok with the submitted values and the whole lifecycle would complete right through the action method.  The code change to _SelectItemsUtil.matchValue methodfor 1.1.5 no longer does the conversion, so the validation phase basically says the submitted value is not one of the values in the selection items, so causes the lifecycle to exit without executing the action method.

As the change made to Myfaces brings it in line with the spec, our jsp-code was not compatible with the spec, so we will change our jsp accordingly. Now we are like this:
<h:selectOneRadio value="#{myBean.someBooleanProperty}" converter="javax.faces.Boolean"  ...>
  <f:selectItems value="#{myBean.yesNoSelectItems}"/>
</h:selectOneRadio>

getYesNoSelectItems() returns SelectItem[]  , each whose item value is  Boolean object.


> UISelectOne and UISelectMany fail with custom converter that returns java.lang.String from getAsObject() method.
> ----------------------------------------------------------------------------------------------------------------
>
>                 Key: MYFACES-1328
>                 URL: https://issues.apache.org/jira/browse/MYFACES-1328
>             Project: MyFaces Core
>          Issue Type: Bug
>    Affects Versions: 1.1.4-SNAPSHOT
>            Reporter: Alexey Maslov
>         Assigned To: Martin Marinschek
>             Fix For: 1.1.5
>
>         Attachments: reproducer.zip
>
>
> The problem seems to be in javax.faces.component._SelectItemsUtil.matchValue(FacesContext context, Object value, Iterator selectItemsIter, _ValueConverter converter) method.
> Line 63-72:
>                 Object itemValue = item.getValue();
>                 if(converter != null && itemValue instanceof String)
>                 {
>                     itemValue = converter.getConvertedValue(context, (String)itemValue);
>                 }
>                 if (value==itemValue || value.equals(itemValue))
>                 {
>                     return true;
>                 }
> If item's value is java.lang.String then this code does duplicate conversion making matchValue() return false and subsequently resulting in error in calling method (validateValue() in javax.faces.component.UISelectOne and javax.faces.component.UISelectMany).

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (MYFACES-1328) UISelectOne and UISelectMany fail with custom converter that returns java.lang.String from getAsObject() method.

Posted by "Nikolay Petrov (JIRA)" <de...@myfaces.apache.org>.
    [ http://issues.apache.org/jira/browse/MYFACES-1328?page=comments#action_12436990 ] 
            
Nikolay Petrov commented on MYFACES-1328:
-----------------------------------------

I really don't see a reason to put conversion:
                if(converter != null && itemValue instanceof String)
                {
                    itemValue = converter.getConvertedValue(context, (String)itemValue);
                }
in this case. A possible solution would be to remove conversion at all (as it is within ri).

May be there is some special case to handle out. Can anybody made something up?


> UISelectOne and UISelectMany fail with custom converter that returns java.lang.String from getAsObject() method.
> ----------------------------------------------------------------------------------------------------------------
>
>                 Key: MYFACES-1328
>                 URL: http://issues.apache.org/jira/browse/MYFACES-1328
>             Project: MyFaces Core
>          Issue Type: Bug
>    Affects Versions: 1.1.4-SNAPSHOT
>            Reporter: Alexey Maslov
>         Attachments: reproducer.zip
>
>
> The problem seems to be in javax.faces.component._SelectItemsUtil.matchValue(FacesContext context, Object value, Iterator selectItemsIter, _ValueConverter converter) method.
> Line 63-72:
>                 Object itemValue = item.getValue();
>                 if(converter != null && itemValue instanceof String)
>                 {
>                     itemValue = converter.getConvertedValue(context, (String)itemValue);
>                 }
>                 if (value==itemValue || value.equals(itemValue))
>                 {
>                     return true;
>                 }
> If item's value is java.lang.String then this code does duplicate conversion making matchValue() return false and subsequently resulting in error in calling method (validateValue() in javax.faces.component.UISelectOne and javax.faces.component.UISelectMany).

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