Uploaded image for project: 'MyFaces Trinidad'
  1. MyFaces Trinidad
  2. TRINIDAD-830

tr:selectOneRadio - no preselection (default value) with java 5 enums

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • None
    • 1.0.5-core, 1.2.5-core
    • Components
    • None

    Description

      sample scenario:

      public class Person
      {
      ...
      private Character gender; //I chose Character to compare possibilities

      //+ getter and setter methods
      }

      -> within tr:selectOneRadio the following two selectItems work very well:
      <tr:selectItem label="#

      {messages.female}" value="f" .../>
      <tr:selectItem label="#{messages.male}" value="m" .../>

      ("f" and "m" is important for the comparison)

      the example above also works with a java 5 enum with one exception - preselected values:
      e.g.:

      public enum Gender
      {
      female, male
      }

      ->
      public class Person
      {
      ...
      private Gender gender;

      //+ getter and setter methods
      }

      in comparison to the first example it would be logical to use the following possibility (with the enum version of this example):

      <tr:selectItem label="#{messages.female}

      " value="female" .../>
      <tr:selectItem label="#

      {messages.male}" value="male" .../>

      this version of the example works well with the exception of the preselected/default value
      (e.g. if the page is redisplayed and should provide the previous entered value(s) or a simple default selection which is not reasonable for this gender example...)



      at the moment the following workaround is possible:

      <tr:selectItem label="#{messages.female}" value="#{pageBean.female}" ..."/>
      <tr:selectItem label="#{messages.male}

      " value="#

      {pageBean.male}

      " ..."/>

      within pageBean:
      public Gender getFemale()
      {
      return Gender.female;
      }

      public Gender getMale()
      {
      return Gender.male;
      }

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              gpetracek Gerhard Petracek
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: