You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@myfaces.apache.org by "gui (JIRA)" <de...@myfaces.apache.org> on 2010/03/18 15:12:27 UTC

[jira] Created: (MYFACES-2614) EnumConverter uses toString() instead of name()

EnumConverter uses toString() instead of name()
-----------------------------------------------

                 Key: MYFACES-2614
                 URL: https://issues.apache.org/jira/browse/MYFACES-2614
             Project: MyFaces Core
          Issue Type: Bug
    Affects Versions: 1.2.8
            Reporter: gui


Hi, 

I have an enum that has overridden the toString method. 
It seems the EnumConverter uses toString to convert an enum to a string (and Enum.valueOf(..) to find it back). However, since my toString is overriden, the value it returns is not valid input for the Enum.valueOf(..) function and the converter raises an exception. 

A better approach is to use .name() as string representation of an Enum. 

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


Re: [jira] Resolved: (MYFACES-2614) EnumConverter uses toString() instead of name()

Posted by Jakob Korherr <ja...@gmail.com>.
Great, thanks Ed!

Are you planning to change this for JSF 1.2 too or will this just stay in
the JSF 2.0 spec?

Regards,
Jakob

2010/3/19 Ed Burns <ed...@oracle.com>

> >>>>> On Fri, 19 Mar 2010 10:41:27 +0000 (UTC), "Jakob Korherr (JIRA)" <
> dev@myfaces.apache.org> said:
>
> JK>      [
> https://issues.apache.org/jira/browse/MYFACES-2614?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel]
>
> JK> Jakob Korherr resolved MYFACES-2614.
> JK> ------------------------------------
>
> JK>        Resolution: Fixed
> JK>     Fix Version/s: 2.0.0-beta-3
> JK>                    1.2.9-SNAPSHOT
>
> >> EnumConverter uses toString() instead of name()
> >> -----------------------------------------------
> >>
> >> Key: MYFACES-2614
> >> URL: https://issues.apache.org/jira/browse/MYFACES-2614
> >> Project: MyFaces Core
> >> Issue Type: Bug
> >> Affects Versions: 1.2.8, 2.0.0-beta-3
> >> Reporter: gui
> >> Assignee: Jakob Korherr
> >> Fix For: 1.2.9-SNAPSHOT, 2.0.0-beta-3
> >>
> >>
> >> Hi,
> >> I have an enum that has overridden the toString method.
> >> It seems the EnumConverter uses toString to convert an enum to a string
> (and Enum.valueOf(..) to find it back). However, since my toString is
> overriden, the value it returns is not valid input for the Enum.valueOf(..)
> function and the converter raises an exception.
> >> A better approach is to use .name() as string representation of an Enum.
>
> This issue seems to be identical to
> <
> https://javaserverfaces-spec-public.dev.java.net/issues/show_bug.cgi?id=470
> >,
> so I have copied it there.
>
> Ed
>
>
> --
> | edward.burns@oracle.com  | office: 408 884 9519 OR x31640
> | homepage:                | http://ridingthecrest.com/
>

Re: [jira] Resolved: (MYFACES-2614) EnumConverter uses toString() instead of name()

Posted by Ed Burns <ed...@oracle.com>.
>>>>> On Fri, 19 Mar 2010 10:41:27 +0000 (UTC), "Jakob Korherr (JIRA)" <de...@myfaces.apache.org> said:

JK>      [ https://issues.apache.org/jira/browse/MYFACES-2614?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

JK> Jakob Korherr resolved MYFACES-2614.
JK> ------------------------------------

JK>        Resolution: Fixed
JK>     Fix Version/s: 2.0.0-beta-3
JK>                    1.2.9-SNAPSHOT

>> EnumConverter uses toString() instead of name()
>> -----------------------------------------------
>> 
>> Key: MYFACES-2614
>> URL: https://issues.apache.org/jira/browse/MYFACES-2614
>> Project: MyFaces Core
>> Issue Type: Bug
>> Affects Versions: 1.2.8, 2.0.0-beta-3
>> Reporter: gui
>> Assignee: Jakob Korherr
>> Fix For: 1.2.9-SNAPSHOT, 2.0.0-beta-3
>> 
>> 
>> Hi, 
>> I have an enum that has overridden the toString method. 
>> It seems the EnumConverter uses toString to convert an enum to a string (and Enum.valueOf(..) to find it back). However, since my toString is overriden, the value it returns is not valid input for the Enum.valueOf(..) function and the converter raises an exception. 
>> A better approach is to use .name() as string representation of an Enum. 

This issue seems to be identical to
<https://javaserverfaces-spec-public.dev.java.net/issues/show_bug.cgi?id=470>,
so I have copied it there.

Ed


-- 
| edward.burns@oracle.com  | office: 408 884 9519 OR x31640
| homepage:                | http://ridingthecrest.com/

[jira] Resolved: (MYFACES-2614) EnumConverter uses toString() instead of name()

Posted by "Jakob Korherr (JIRA)" <de...@myfaces.apache.org>.
     [ https://issues.apache.org/jira/browse/MYFACES-2614?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Jakob Korherr resolved MYFACES-2614.
------------------------------------

       Resolution: Fixed
    Fix Version/s: 2.0.0-beta-3
                   1.2.9-SNAPSHOT

> EnumConverter uses toString() instead of name()
> -----------------------------------------------
>
>                 Key: MYFACES-2614
>                 URL: https://issues.apache.org/jira/browse/MYFACES-2614
>             Project: MyFaces Core
>          Issue Type: Bug
>    Affects Versions: 1.2.8, 2.0.0-beta-3
>            Reporter: gui
>            Assignee: Jakob Korherr
>             Fix For: 1.2.9-SNAPSHOT, 2.0.0-beta-3
>
>
> Hi, 
> I have an enum that has overridden the toString method. 
> It seems the EnumConverter uses toString to convert an enum to a string (and Enum.valueOf(..) to find it back). However, since my toString is overriden, the value it returns is not valid input for the Enum.valueOf(..) function and the converter raises an exception. 
> A better approach is to use .name() as string representation of an Enum. 

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


[jira] Reopened: (MYFACES-2614) EnumConverter uses toString() instead of name()

Posted by "Leonardo Uribe (JIRA)" <de...@myfaces.apache.org>.
     [ https://issues.apache.org/jira/browse/MYFACES-2614?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Leonardo Uribe reopened MYFACES-2614:
-------------------------------------


the javadoc of EnumConverter is different in 1.2.x and 2.0.x in 1.2.x uses toString(), but in 2.0.x uses name(). In fact, it is an spec issue, and it was solved on 2.0.x branch, but since the javadoc in 1.2.x says cleary that we should use toString(), we cannot fix it there. A solution for this is create a custom converter.

> EnumConverter uses toString() instead of name()
> -----------------------------------------------
>
>                 Key: MYFACES-2614
>                 URL: https://issues.apache.org/jira/browse/MYFACES-2614
>             Project: MyFaces Core
>          Issue Type: Bug
>    Affects Versions: 1.2.8, 2.0.0-beta-3
>            Reporter: gui
>            Assignee: Jakob Korherr
>             Fix For: 1.2.9-SNAPSHOT, 2.0.0-beta-3
>
>
> Hi, 
> I have an enum that has overridden the toString method. 
> It seems the EnumConverter uses toString to convert an enum to a string (and Enum.valueOf(..) to find it back). However, since my toString is overriden, the value it returns is not valid input for the Enum.valueOf(..) function and the converter raises an exception. 
> A better approach is to use .name() as string representation of an Enum. 

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


[jira] Resolved: (MYFACES-2614) EnumConverter uses toString() instead of name()

Posted by "Jakob Korherr (JIRA)" <de...@myfaces.apache.org>.
     [ https://issues.apache.org/jira/browse/MYFACES-2614?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Jakob Korherr resolved MYFACES-2614.
------------------------------------

       Resolution: Fixed
    Fix Version/s:     (was: 1.2.9-SNAPSHOT)

As Leonardo wrote, we can only fix this for MyFaces 2.0, because the spec javadoc of JSF 1.2 specificly says that we have to use toString().

So if you don't want to change your application to use JSF 2.0, I am afraid you have to use a custom converter. Sorry, but that is all we can do for this one!

> EnumConverter uses toString() instead of name()
> -----------------------------------------------
>
>                 Key: MYFACES-2614
>                 URL: https://issues.apache.org/jira/browse/MYFACES-2614
>             Project: MyFaces Core
>          Issue Type: Bug
>    Affects Versions: 1.2.8, 2.0.0-beta-3
>            Reporter: gui
>            Assignee: Jakob Korherr
>             Fix For: 2.0.0-beta-3
>
>
> Hi, 
> I have an enum that has overridden the toString method. 
> It seems the EnumConverter uses toString to convert an enum to a string (and Enum.valueOf(..) to find it back). However, since my toString is overriden, the value it returns is not valid input for the Enum.valueOf(..) function and the converter raises an exception. 
> A better approach is to use .name() as string representation of an Enum. 

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


[jira] Commented: (MYFACES-2614) EnumConverter uses toString() instead of name()

Posted by "Leonardo Uribe (JIRA)" <de...@myfaces.apache.org>.
    [ https://issues.apache.org/jira/browse/MYFACES-2614?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12847360#action_12847360 ] 

Leonardo Uribe commented on MYFACES-2614:
-----------------------------------------

Look this one:

https://javaserverfaces-spec-public.dev.java.net/issues/show_bug.cgi?id=470

> EnumConverter uses toString() instead of name()
> -----------------------------------------------
>
>                 Key: MYFACES-2614
>                 URL: https://issues.apache.org/jira/browse/MYFACES-2614
>             Project: MyFaces Core
>          Issue Type: Bug
>    Affects Versions: 1.2.8, 2.0.0-beta-3
>            Reporter: gui
>            Assignee: Jakob Korherr
>             Fix For: 1.2.9-SNAPSHOT, 2.0.0-beta-3
>
>
> Hi, 
> I have an enum that has overridden the toString method. 
> It seems the EnumConverter uses toString to convert an enum to a string (and Enum.valueOf(..) to find it back). However, since my toString is overriden, the value it returns is not valid input for the Enum.valueOf(..) function and the converter raises an exception. 
> A better approach is to use .name() as string representation of an Enum. 

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


[jira] Commented: (MYFACES-2614) EnumConverter uses toString() instead of name()

Posted by "Jakob Korherr (JIRA)" <de...@myfaces.apache.org>.
    [ https://issues.apache.org/jira/browse/MYFACES-2614?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12847361#action_12847361 ] 

Jakob Korherr commented on MYFACES-2614:
----------------------------------------

Quote from the 2.0 spec javadoc of EnumConverter: "..casting it to a java.lang.Enum and returning the result of calling the name() method.."

> EnumConverter uses toString() instead of name()
> -----------------------------------------------
>
>                 Key: MYFACES-2614
>                 URL: https://issues.apache.org/jira/browse/MYFACES-2614
>             Project: MyFaces Core
>          Issue Type: Bug
>    Affects Versions: 1.2.8, 2.0.0-beta-3
>            Reporter: gui
>            Assignee: Jakob Korherr
>             Fix For: 1.2.9-SNAPSHOT, 2.0.0-beta-3
>
>
> Hi, 
> I have an enum that has overridden the toString method. 
> It seems the EnumConverter uses toString to convert an enum to a string (and Enum.valueOf(..) to find it back). However, since my toString is overriden, the value it returns is not valid input for the Enum.valueOf(..) function and the converter raises an exception. 
> A better approach is to use .name() as string representation of an Enum. 

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