title: How can I get the value of selected item from selectOneMenu component?
body: <p>I have the following addService.xhtml</p>
  
  <pre><code>&lt;html xmlns="http://www.w3.org/1999/xhtml"
  xmlns:h="http://java.sun.com/jsf/html"
  xmlns:f="http://java.sun.com/jsf/core"
  xmlns:p="http://primefaces.org/ui"&gt;
  
  &lt;h:head&gt;&lt;title&gt;Add Service&lt;/title&gt;&lt;/h:head&gt;
  &lt;h:body&gt;
      &lt;h:form&gt;
          &lt;p:outputLabel for="name" value="Service Name" /&gt;
          &lt;p:inputText id="name" value="#{serviceMB.name}"&gt;&lt;/p:inputText&gt;
  
          &lt;p:outputLabel for="categoryCompId" value="Service Category" /&gt;
          &lt;p:selectOneMenu id="categoryCompId" value="#{serviceMB.selectedCategory}" &gt;
              &lt;f:selectItem itemLabel="Select Category" itemValue="" noSelectionOption="true" /&gt;
              &lt;f:selectItems value="#{serviceMB.categories}" var="category" itemLabel="#{category.name}" itemValue="#{category}"/&gt;
          &lt;/p:selectOneMenu&gt;
          &lt;p:commandButton id="saveService" value="Save" action="#{serviceMB.saveServiceAndExit}"/&gt;
      &lt;/h:form&gt;
  &lt;/h:body&gt;
  </code></pre>
  
  <p></p>
  
  <p>And the following managed bean</p>
  
  <pre><code>@Component
  @Controller
  @Scope(value = "request")
  @ManagedBean(name="serviceMB")
  @RequestScoped
  public class ServicesManagedBean implements Serializable {
      private Category selectedCategory;
      private String name;
      public Category getSelectedCategory() {
          return selectedCategory;
      }
      public void setSelectedCategory(Category selectedCategory) {
          this.selectedCategory = selectedCategory;
      }
      public String getName() {
          return name;
      }
      public void setName(String name) {
          this.name = name;
      }
      public List&lt;Category&gt; getCategories() {
          return categoryService.getCategories();
      }
  </code></pre>
  
  <p>}</p>
  
  <p>The <code>setSelectedCategory()</code> method doesn't be called and <code>selectedCategory</code> field is always null, although I'm using it in the <code>&lt;p:selectOneMenu</code>. Is there anything wrong in my code?</p>
  
  <p>I've added a converter, but when I use <code>Object selectedObject = ((HtmlSelectOneMenu) arg1).getValue();</code> it returns null also.</p>