6 Replies Latest reply on Feb 18, 2008 3:23 AM by koen handekyn

    selectOneMenu preselection

    Ben Wen Newbie

      Hi all,

      I want to have my drop down value pre-selected with appropriate option when user visit the page.

      The following is my page for showing role selection dropdown.

       <s:decorate id="role" template="layout/display.xhtml">
       <ui:define name="label">role</ui:define>
       #{wiseUser.wiseUserRole.roleName}
       </s:decorate>
      
       <s:decorate id="valueDecoration" template="layout/edit.xhtml">
       <ui:define name="label">Title</ui:define>
       <h:selectOneMenu value="#{wiseUser.wiseUserRole}">
       <s:selectItems value="#{wurList}" var="wur" label="#{wur.roleName}" noSelectionLabel="Please select" />
       <s:convertEntity />
       </h:selectOneMenu>
       </s:decorate>
      


      My WiseUser entity has a mapping to WiseUserRole
       @ManyToOne(fetch = FetchType.LAZY)
       //@ManyToOne(fetch = FetchType.EAGER)
       @JoinColumn(name = "UserRole")
       public WiseUserRole getWiseUserRole() {
       return this.wiseUserRole;
       }
      


      When use FetchType.EAGER, then the dropdown box is correctly preselected with the user's role, however when FetchType.LAZY it's always present "Please select" option.

      How to get the dropdown correctly preselected without using the EAGER fetching?