Details

    • Issuezilla Id:
      470
    • Status Whiteboard:
      Hide

      EGEasy5 cat2 javadoc size_large importance_medium

      Show
      EGEasy5 cat2 javadoc size_large importance_medium

      Description

      I'm confused as to how javax.faces.convert.EnumConverter is ever supposed to
      work. It basically does:

      getAsString: value.toString();
      getAsObject: Enum.valueOf( targetClass, value );

      But Enum.valueOf was never designed to be the opposite of value.toString(). The
      JavaDoc says it is the opposite of value.name(). So if you ever override an
      enum value to have a different toString than its name (a common occurence)...

      enum Gender {
      MALE {
      public String toString()

      { return "Male"; }

      }

      ...then EnumConverter won't work for you. Surely this is a bug in the spec?

      For a long time now I've been using my own EnumConverter with JSF 1.1. It
      does...

      getAsString: if ( component instanceof UIInput ) return value.name() else
      value.toString();
      getAsObject: Enum.valueOf( targetClass, value );

      ...so there's a caveat when you're using labels (when you really do want
      the .toString() instead of the .name() to appear), but for UIInputs (eg.
      UISelects) you need to use the name() or it will never convert back.

      Can this design decision be double checked for JSF 2.0?

      Thanks,

      Richard.

        Activity

        Hide
        Ed Burns added a comment -

        These are targeted at 2.1.

        Show
        Ed Burns added a comment - These are targeted at 2.1.
        Hide
        Ed Burns added a comment -

        triage

        Show
        Ed Burns added a comment - triage
        Hide
        rogerk added a comment -

        triage

        Show
        rogerk added a comment - triage
        Hide
        Ed Burns added a comment -

        Set priority to baseline ahead of JSF 2.3 triage. Priorities will be assigned accurately after this exercise.

        Show
        Ed Burns added a comment - Set priority to baseline ahead of JSF 2.3 triage. Priorities will be assigned accurately after this exercise.
        Hide
        Ed Burns added a comment -

        Leave priority unchanged.

        Show
        Ed Burns added a comment - Leave priority unchanged.

          People

          • Assignee:
            Unassigned
            Reporter:
            kennardconsulting
          • Votes:
            3 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated: