title: Not getting selected value from Dropdown in primefaces backing bean
body: <p>Hi I have built two consecutive dropdowns one being initialized in init() method and the other being populated on the basis on first one's selection.</p>
  
  <p>Command Button is used to use both the selected values for processing, Strange that Setter for the selected values is being called twice(setting blank the second time..as I found out in debugging)..I need understand whyu I am getting blank values?</p>
  
  <p><strong>myPage.xhtml</strong></p>
  
  <pre><code>&lt;p:selectOneMenu id="dbList"
      value="#{backingBean.selectedConnection}"
      style="width:200px"&gt;
      &lt;p:ajax listener="#{backingBean.onConnectionChange()}"
          update="aliasList" /&gt;
      &lt;f:selectItem itemLabel="Select" itemValue="#{backingBean.selectedConnection}"
          noSelectionOption="false" /&gt;
      &lt;f:selectItems value="#{backingBean.connectionsTypeList}" /&gt;
  &lt;/p:selectOneMenu&gt;
  &lt;p:outputLabel for="aliasList" value="Connection Alias" /&gt;
  &lt;p:selectOneMenu id="aliasList"
      value="#{backingBean.aliasSelected}" style="width:200px"&gt;
      &lt;f:selectItem itemLabel="Select" itemValue="#{backingBean.aliasSelected}"
          noSelectionOption="false"/&gt;
      &lt;f:selectItems value="#{backingBean.connectionsList}" /&gt;
  &lt;/p:selectOneMenu&gt;
  &lt;p:commandButton value="myButton" 
      actionListener="#{backingBean.myMethod()}"
      id="myButton" /&gt;                                            
  </code></pre>
  
  <p><strong>backingBean.java</strong></p>
  
  <pre><code>@ManagedBean
  @ViewScoped
  public class BackingBean implements Serializable {
      /**
       * 
       */
      private static final long serialVersionUID = 1L;
      private ArrayList&lt;String&gt; connectionsList;
      private String aliasSelected;
      private String selectedConnection;
      private ArrayList&lt;String&gt; connectionsTypeList;
  
      @PostConstruct
      public void init() {
          // Initialize the connection alias drop down here
          this.connectionsTypeList = getConnectionTypeList();
          this.connectionsList=new ArrayList&lt;String&gt;();
      }
  
      public void onConnectionChange() {
          System.out.println("In Connection Change, populating aliases");
          getConnectionDBList();
  
      }
      public String getAliasSelected() {
          return aliasSelected;
      }
  //Dont know why this is called twice on button click and second time value set is blank
      public void setAliasSelected(String aliasSelected) {
          this.aliasSelected = aliasSelected;
      }
  
      public ArrayList&lt;String&gt; getConnectionsList() {
          return connectionsList;
      }
  
      public void setConnectionsList(ArrayList&lt;String&gt; connectionsList) {
          this.connectionsList = connectionsList;
      }
      public String getSelectedConnection() {
          return selectedConnection;
      }
  
      public void setSelectedConnection(String selectedConnection) {
          this.selectedConnection = selectedConnection;
      }
  
      public ArrayList&lt;String&gt; getConnectionsTypeList() {
          return connectionsTypeList;
      }
  
      public void setConnectionsTypeList(ArrayList&lt;String&gt; connectionsTypeList) {
          this.connectionsTypeList = connectionsTypeList;
      }
      public void myMethod() {
          System.out.println("selected Alias is "+aliasSelected);
          System.out.println("selected connection is "+selectedConnection);
      }
  }
  </code></pre>
  
  <p>New to primefaces,please help</p>