title: How to populate and preselect a h:selectOneMenu?
body: <p>I have a problem in populaing dropdown value based on ID.</p>
  
  <p>View: </p>
  
  <pre class="lang-html prettyprint-override"><code>&lt;h:selectOneMenu id="dropDown" value="#{sampleVo.dropDownType}" "&gt;
      &lt;f:selectItem itemValue="Select Value" itemLabel="Select Value" /&gt;
      &lt;f:selectItems value="#{sampleService.dropDownList}" /&gt;
  &lt;/h:selectOneMenu&gt;
  </code></pre>
  
  <p><code>SampleVo</code>:</p>
  
  <pre><code>public class SampleVo implements Serializable {
  
      private String dropDownType;
  
      // getters and setters
  }
  </code></pre>
  
  <p><code>SampleService</code>:</p>
  
  <pre><code>public class SampleServiceImpl implements SampleService {
  
      private List&lt;SampleVo&gt; listOfSampleVo;
      private List&lt;String&gt; dropDownList;
  
      public void onLoad() {
          dropDownFunction();
      }
  
      public void dropDownFunction() {
          if (dropDownList == null) {
              dropDownList = new ArrayList&lt;String&gt;();
              dropDownList.add("ONE");
              dropDownList.add("TWO");
              dropDownList.add("THREE");
          }
      }   
  
  }
  </code></pre>
  
  <p>DB Structure:</p>
  
   <pre class="lang-none prettyprint-override"><code>    SAMPLE_ID       SAMPLE_DESCRIPTION
          1                   ONE
          2                   TWO
          3                   THREE
  </code></pre>
  
  <p>During the page loading, all three drop down values would get populated with default "select value" as the first option. Drop down values are mapped to database, with sample ID. If a record exists in DB (i.e sample id = 2, sample description = TWO), I want to show two in drop down based on ID. How can I achieve this?</p>