[jbossseam-issues] [JBoss JIRA] Commented: (JBSEAM-2346) s:selectItems - noSelectionLabel is not hidden after first selection of a value

Kahli Burke (JIRA) jira-events at lists.jboss.org
Thu Dec 13 23:08:53 EST 2007


    [ http://jira.jboss.com/jira/browse/JBSEAM-2346?page=comments#action_12392120 ] 
            
Kahli Burke commented on JBSEAM-2346:
-------------------------------------

Oops sorry that was the wrong URL, here is the correct one:

http://www.jboss.com/index.html?module=bb&op=viewtopic&t=125722


> s:selectItems - noSelectionLabel is not hidden after first selection of a value
> -------------------------------------------------------------------------------
>
>                 Key: JBSEAM-2346
>                 URL: http://jira.jboss.com/jira/browse/JBSEAM-2346
>             Project: JBoss Seam
>          Issue Type: Bug
>          Components: JSF
>         Environment: CVS-based Seam 2.0.1
>            Reporter: Wolfgang Schwendt
>            Priority: Minor
>             Fix For: 2.0.1.GA
>
>
> <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.
>  

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.jboss.com/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the seam-issues mailing list