Uploaded image for project: 'Seam 2'
  1. Seam 2
  2. JBSEAM-2346

s:selectItems - noSelectionLabel is not hidden after first selection of a value

    Details

    • Type: Bug
    • Status: Open (View Workflow)
    • Priority: Critical
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: The future
    • Component/s: JSF Controls
    • Labels:
      None
    • Environment:

      CVS-based Seam 2.0.1

      Description

      <s:selectItems> offers that the user can specify an (optional) "noSelectionLabel" to be placed at the top of the selection list. It further provides a hideNoSelectionLabel option – if this property is true, the noSelectionLabel will be hidden when a value is selected.

      And exactly the latter functionality has a bug, but only as far as the user's FIRST selection is concerned. When the users makes his first selection and submits the form, then the noSelectionLabel is still displayed when the page is redisplayed by the server, no matter whether or not hideNoSelection was set to "true". However, when the users makes additional requests, the hideNoSelectionLabel functionality works correctly.

      Reason for the bug: caching behavior of org.jboss.seam.ui.component.UISelectItems.getValue()

      Too understand why there is a bug, consider the following scenario:

      A page with <h:selectOneMenu> and <s:selectItems var="myVar" label="#

      {myVar.name}

      " value="#

      {resultList}

      " noSelectionLabel="* Your choice please *" hideNoSelectionLabel="true"/> as its child component.

      When the user makes a selection and submits the form, the UISelectOne components checks during the "Process validations" JSF phase whether the submitted input value matches one of the available options (SelectItems). Consequently, the UISelectOne component calls the getValue() method of its org.jboss.seam.ui.component.UISelectItems child component in order to retrieve a list of SelectItem s. Then, if if validation was successful because a matching value was found, the user's selection is either written to the model (during JSF Update model phase) or if we don't make it to the Update model phase, because some other component had a validation error, the user's selection is stored in the value property of the UISelectOne component.

      When we finally reach the "Render response" phase and the same page should be redisplayed, the UISelectOne component gets rendered again. In order to render the selection list items, org.jboss.seam.ui.component.UISelectItems.getValue() gets called another time.

      But now it doesn't re-calculate its list of SelectItems. Take a look at the code:

      org.jboss.seam.ui.component.UISelectItems.getValue()

      @Override
      public Object getValue()
      {
      if (value == null || originalValue == null || !originalValue.equals(super.getValue()))

      { ... }

      return value;
      }

      Note that "value" is not null, because during "Process validations" org.jboss.seam.ui.component.UISelectItems.getValue() was already called which lead to value being set. Therefore, getValue() returns the OLD cached list of SelectItem s, which was calculated during Process Validations and therefore still includes the noSelectionLabel! And therefore getValue() doesn't take into account that the user made a selection and that the noSelectionLabel should now be hidden.

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  pmuir Pete Muir
                  Reporter:
                  wschwendt Wolfgang Schwendt
                • Votes:
                  11 Vote for this issue
                  Watchers:
                  10 Start watching this issue

                  Dates

                  • Created:
                    Updated: