2 Replies Latest reply on Sep 11, 2007 7:49 PM by John Franey

    DataModelSelection is always the first option after 'unselec

    John Franey Novice

      I'm using jboss 4.2.1 and seam 2.0 beta1. I used seam-gen to initialize the project.

      I'm using h:selectOneMenu and s:selectItems in conjunction with @DataModel and @DataModelSelection.

      I've been banging my head on this for a while and can't understand it even now. Can anyone please shed light?

      The @DataModelSelection variable always contains the first option of the select items no matter what selection was made in the browser.

      For example, for the page source result below, no matter what the user selects, the variable marked with @DataModelSelections will ALWAYS have the value of the second option in the list ('location 1')


      <select id="masterAccountSelect:customerName" name="masterAccountSelect:customerName" size="1">
       <option value="org.jboss.seam.ui.NoSelectionConverter.noSelectionValue">Select Customer</option>
       <option value="0">(xxx) location 1</option>
       <option value="1">(yyy) location 2</option>
       <option value="2">(zzz) location 3</option>
       ...
      


      Here is segment of my xhtml:

       <rich:panel>
       <f:facet name="header">Select Master Account</f:facet>
      
       <div class="dialog">
       <h:panelGrid columns="2" rowClasses="prop" columnClasses="name,value">
       <h:outputLabel for="customerName">Customer Name</h:outputLabel>
       <h:selectOneMenu id="customerName" value="#{location}">
       <s:selectItems value="#{allLocations}"
       var="loc" label="(#{loc.loginSid}) #{loc.name}" noSelectionLabel="Select Customer" />
       <s:convertEntity/>
       </h:selectOneMenu>
      
       </h:panelGrid>
       <h:panelGrid columns="2" rowClasses="prop" columnClasses="name,value">
       <h:outputLabel for="loginSid">Login SID</h:outputLabel>
       <h:inputText id="loginSid"
       value="#{location.loginSid}"/>
       </h:panelGrid>
       </div>
      
       <div class="actionButtons">
       <h:commandButton value="Select By Name" action="#{mapSubAccountsHelper1.selectLocationByName}"/>
       </div>
       <div class="actionButtons">
       <h:commandButton value="Select By Login SID" action="#{mapSubAccountsHelper1.selectLocationByLoginSid}"/>
       </div>
       </rich:panel>
      
      


      Here is segment of my bean:

      @Stateful
      @Name("mapSubAccountsHelper1")
      public class MapSubAccountsHelper1 implements Serializable, MapSubAccountsHelper1Local {
      
      ...
       @DataModel
       private List<Location> allLocations;
      
      
       @DataModelSelection
       private Location location;
      
      ...
      
       public void selectLocationByLoginSid() {
       logger.debug("selectLocationByLoginSid: " + location.getLoginSid());
      ...
      
       }
      
      
       public void selectLocationByName() {
       logger.debug("selectLocationByName: " + location.getName());
      ....
      
       }
      
      ....
      
       @Factory("allLocations")
       @Begin(join=true)
       public void buildAllLocations() {
      .....
       }
      
      


      If more information is needed, please let me know.

      Thanks,
      John