title: How to store value of selectOneMenu in controller class variable using JSF and PrimeFaces
body: <p>Inside my controller <code>StudentController</code> I have a variable <code>Course course</code> and I want to set this variable with the value, selected in a <code>selectOneMenu</code>, inside my JSF-page. Clicking the save-button would temporarily just call the JSF-page <code>index</code> (I will fill that part with my own code that will persist the student course, which will not be a problem).
  The corresponding part in my JSF-page:</p>
  
  <pre><code>&lt;h:form&gt;
      &lt;h:panelGrid columns="2" style="margin-bottom:10px" cellpadding="5"&gt;
          &lt;p:outputLabel for="course" value="Select Course:" /&gt;
          &lt;p:selectOneMenu id="course" value="#{studentController.course}"&gt;
              &lt;f:selectItem itemLabel="--- Please Select ---" itemValue="" /&gt;
              &lt;f:selectItems value="#{studentController.courses}" var="course"
                  itemLabel="#{course.name}" itemValue="#{course}" /&gt;
          &lt;/p:selectOneMenu&gt;
      &lt;/h:panelGrid&gt;
      &lt;p:commandButton action="index?faces-redirect=true"
          value="Save" icon="ui-icon-circle-check" /&gt;
  &lt;/h:form&gt;
  </code></pre>
  
  <p>The corresponding part in the controller:</p>
  
  <pre><code>@ManagedBean
  @SessionScoped
  public class StudentController {
  
      // list contains available courses, is not empty
      private List&lt;Course&gt; courses;
  
      private Course course = new Course();
  
      // getter, setter and other functionality
  }
  </code></pre>
  
  <p>When I click the save-button, nothing happens. No error messages in my console, no redirecting.
  How can I store the value, selected on the <code>selectOneMenu</code> inside my <code>course</code> variable?</p>