Uploaded image for project: 'Struts 2'
  1. Struts 2
  2. WW-1738

Inconsistency between s:combobox and s:select behaviour.

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.0.5
    • 2.0.6
    • None
    • None

    Description

      Let's take the example of a simple SexType enumeration

      {MALE, FEMALE}

      , that is used in conjunction with the EnumTypeConverter.

      so, the action contains a pair of get/set for SexType ., as well as a getter for sexTraitTypes which returns a list of Key Value Pairs<SexType, String>, (the String is the label)

      <s:select
      list="sexTraitTypes"
      label="%

      {getText('profile.label.sex')}"
      name="sexTrait"
      listKey="key"
      listValue="value"
      emptyOption="true" />
      does NOT preselect anything whereas


      <s:combobox
      list="sexTraitTypes"
      label="%{getText('profile.label.sex')}

      "
      name="sexTrait"
      listKey="key"
      listValue="value"
      emptyOption="true" />

      will automatically preselect the value given by getSexTrait();

      Ok, so now, if we use :
      <s:select
      list="sexTraitTypes"
      label="%

      {getText('profile.label.sex')}"
      name="sexTrait"
      value="sexTrait"
      listKey="key"
      listValue="value"
      emptyOption="true" />

      Then, it's no better. And actually, the only way to achieve auto-preselection is :
      <s:select
      list="sexTraitTypes"
      label="%{getText('profile.label.sex')}

      "
      name="sexTrait"
      value="sexTrait.toString()"
      listKey="key"
      listValue="value"
      emptyOption="true" />

      So, I'm not sure if the need for toString() in the value is a bug by itself, but in any case, the fact that s:select is inconsistent with s:combobox would probably benefit of some improvement.....

      Regards,
      Sami Dalouche

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              samokk Sami Dalouche
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: