mardi 4 août 2015

Default Blank Item in f:selectItem dropdown list

I am creating a dropdown menu. I am using the attributes such as hideNoSelectionOption, noSelectionOption, itemLabel="", and itemValue="#{null}" to have a default value that is a blank value and is the first item shown when the page loads. Instead, when the page loads, the default item shown is the last item in the list. One fix I had was putting a blank item last in the list, but I don't like that fix as I want the blank item to be first in the list, and the default item shown when the page loads. Any Suggestions?

                 <tr class="contentRow">
                    <td><span> <h:selectOneMenu
                    styleClass="selectOneMenuLeft" id="menuProgramType" value="#{searchBean.selectedSearchType}"
                    onchange="javascript:displayDivs();" hideNoSelectionOption="true">
                    <f:selectItem noSelectionOption="true" itemLabel=""/>
                    <f:selectItem itemLabel="Item1"  />
                    <f:selectItem itemLabel="Item2" />
                    <f:selectItem itemLabel="Item3"  />
                    <f:selectItem itemLabel="Item4" />
                    </h:selectOneMenu></span></td>

                    <td><span> <h:selectOneMenu
                    styleClass="selectOneMenuLeft" id="menuSystemOfOriginType" value="#{searchBean.selectedSearchType}"
                    onchange="javascript:displayDivs();" hideNoSelectionOption="true" >
                    <f:selectItem itemLabel="" itemValue="#{null}"  noSelectionOption="true" />
                    <f:selectItem itemLabel="FirstItem"  />
                    <f:selectItem itemLabel="SecondItem" />
                    <f:selectItem itemLabel="LastItem"  />
                    </h:selectOneMenu></span></td>
                </tr>

Aucun commentaire:

Enregistrer un commentaire