Changing assigned user using p:selectOneMenu
<p>I have been searching for similar issue but I could not find any. 
so here is the thing</p>

<p>I am trying to create a web application that deals with HR stuff, like employee requests (Resign, loan, vacation, etc..) 
I am using primeface and I have the following problem that I cant figure out. </p>

<p>The thing is I am trying to do is :</p>

<p>1- When user first creates the request and assigns the user and submit the form
the next step is</p>

<p>2- the manager would sees the request and then change the "Person responsible for the request" to a new one using the drop menu in the datatable and I have been trying to solve this problem with no luck.
 Here is the dialog script</p>

<pre><code>&lt;h:form id='resignf'&gt;
&lt;p:dialog id='res' header="Resign Request" widgetVar="resign" minHeight="40"&gt;
        &lt;p:outputLabel value="Employee name" /&gt; 
        &lt;p:inputText value="#{controller.resignName}" required="true" requiredMessage="This field is required" /&gt;

        &lt;p:outputLabel value="Employee Number" /&gt; 
        &lt;p:inputText value="#{controller.resignEmployeNum}" required="true" /&gt;

        &lt;p:inputText value="#{controller.resignNationalIDNum}" required="true"  /&gt;

        &lt;p:inputText value="#{controller.resignNotes}" required="true"  /&gt;

        &lt;p:outputLabel for="AssignUser" value="User" /&gt; 

        &lt;p:selectOneMenu id="AssignUser"  value="#{controller.assignUser}" style="width:150px" converter="UConverter"&gt;
            &lt;f:selectItems value="#{controller.usersList}"  var="user" itemLabel="#{user.username}"/&gt;
        &lt;/p:selectOneMenu &gt;


        &lt;p:commandButton action="#{controller.createResignRequest()}" onclick="PF('resign').hide();" update="@all"/&gt;
    &lt;/p:dialog&gt;
</code></pre>

<p>And the code is my <code>controller.java</code> file below to create the request in the table</p>

<pre><code>/* Request to resign*/
private List&lt;ResignationRequest&gt; resignList;
private ResignationRequestController rController = new ResignationRequestController();

private String resignName;
private String resignEmployeNum;
private String resignNationalIDNum;
private String ResignNotes;
private int AutoAssignToIDNUM;

/* end of request to resign*/

    public void createResignRequest() {

    System.out.println("createResignRequest");
    ResignationRequest newResign = new ResignationRequest();

    newResign.setName(resignName);
    newResign.setEmployeeNum(resignEmployeNum);
    newResign.setNationalID(resignNationalIDNum);

    newResign.setNotes(ResignNotes);

    newResign.setUserID(AssignUser);

    rController.create(newResign);
    resignList = rController.findResignationRequestEntities(); //retrieves all the resigns from the database

}
</code></pre>

<p>Now all that is working perfectly, but when I try to change the old user with the new one here I get confused! so far what I have been thinking is I need to find the old user and then switch him, but I could not figure a way to do it using the select list. The script for for changing the "User responsible for the request" below</p>

<pre><code>&lt;p:dataTable id="resignTable1" cellSeparator="true" editMode="cell" editable="true"  var="resign" value="#{controller.resignList}" paginator="true"    rows="10" rowIndexVar="index1"&gt;
    &lt;p:ajax id="aj" event="cellEdit" listener="#{controller.editUser(user)}" update="resignTable1"/&gt;
    &lt;p:column headerText="Employee number"&gt;
        &lt;p:cellEditor&gt;
            &lt;f:facet name="output"&gt; &lt;h:outputText value="#{resign.employeeNum}" /&gt;&lt;/f:facet&gt;
            &lt;f:facet name="input"&gt; &lt;h:inputText value="#{resign.employeeNum}" /&gt;&lt;/f:facet&gt;
        &lt;/p:cellEditor&gt;
    &lt;/p:column&gt;
    &lt;p:column headerText="name"&gt;
        &lt;p:cellEditor&gt;
            &lt;f:facet name="output"&gt; &lt;h:outputText value="#{resign.name}" /&gt;&lt;/f:facet&gt;
            &lt;f:facet name="input"&gt; &lt;h:inputText value="#{resign.name}" /&gt;&lt;/f:facet&gt;
        &lt;/p:cellEditor&gt;
    &lt;/p:column&gt;
    &lt;p:column headerText="Request Number"&gt;
        &lt;p:cellEditor&gt;
            &lt;f:facet name="output"&gt; &lt;h:outputText value="#{resign.id}" /&gt;&lt;/f:facet&gt;
            &lt;f:facet name="input"&gt; &lt;h:inputText value="#{resign.id}" /&gt;&lt;/f:facet&gt;

        &lt;/p:cellEditor&gt;
    &lt;/p:column&gt;
    &lt;p:column headerText="User responsible for the request"&gt;
        &lt;p:cellEditor&gt;
            &lt;f:facet name="output"&gt; &lt;h:outputText value="#{resign.userID}" /&gt;&lt;/f:facet&gt;
            &lt;f:facet name="input"&gt; &lt;h:inputText value="#{resign.userID}" /&gt;&lt;/f:facet&gt;
        &lt;/p:cellEditor&gt;
    &lt;/p:column&gt;
    &lt;p:column headerText="Comments"&gt;
        &lt;p:cellEditor&gt;
            &lt;f:facet name="output"&gt; &lt;h:outputText value="#{resign.notes}" /&gt;&lt;/f:facet&gt;
            &lt;f:facet name="input"&gt; &lt;h:inputText value="#{resign.notes}" /&gt;&lt;/f:facet&gt;
        &lt;/p:cellEditor&gt;
    &lt;/p:column&gt;
    &lt;p:column headerText="Send the request to the next employee"&gt;
        &lt;p:selectOneMenu id="AssignUser"  value="#{controller.assignUser}" style="width:150px" converter="UConverter" onchange="submit();"&gt;
            &lt;f:selectItems value="#{controller.usersList}"  var="user" itemLabel="#{user.username}"   actionListener="#{controller.editRequestStep(resign)}"  &gt;
            &lt;/f:selectItems&gt;
        &lt;/p:selectOneMenu &gt;
</code></pre>

<p>In my controller file</p>

<pre><code>public void editRequestStep(ResignationRequest r) {

    System.out.println("Edit resign");

    try {
        System.out.println("Edit resign");
        rController.edit(r);

    } catch (Exception ex) {
        Logger.getLogger(Controller.class.getName()).log(Level.SEVERE, null, ex);
    }

}
</code></pre>

<p>I tried to get as much as I could from the code but I have a lot of stuff that I am not sure if I should submit. I tried ajax</p>

<p>NOTE: I am using mySQL, apache tomcat in case if it matters.</p>