SetWrappedData for DataModel isn't working properly
<p>I have a form with a panelGrid, where the user puts in some data:</p>

<pre><code>&lt;h:form&gt;
    &lt;p:panelGrid var="workOrder" value="#{WorkOrder}" columns="2"
        headerClass="header" footerClass="footer"&gt;
        &lt;p:outputLabel value="#{msg.project_number}: " for="projectNr" /&gt;
        &lt;p:column&gt;
            &lt;p:inputText id="projectNr"
                value="#{mbWorkOrderController.workOrderCurrent.projectNr}"
                required="true" requiredMessage="#{msg.input_missing}"
                maxlength="6" /&gt;
        &lt;/p:column&gt;
        &lt;p:outputLabel value="#{msg.date}: " for="date" /&gt;
        &lt;p:column&gt;
            &lt;p:calendar id="date"
                value="#{mbWorkOrderController.workOrderCurrent.date}"
                mode="popup" navigator="true" showOn="button"
                pattern="dd.MM.yyy" /&gt;
        &lt;/p:column&gt;
    &lt;/p:panelGrid&gt;
    &lt;p:commandButton action="#{mbWorkOrderController.saveWorkOrder()}"
        value="#{msg.save}" style="margin-top: 10px" /&gt;
    &lt;p:commandButton
        action="#{mbWorkOrderController.cancelWorkOrder()}"
        value="#{msg.cancel}" immediate="true" style="margin-top: 10px" /&gt;
&lt;/h:form&gt;
</code></pre>

<p>When the user clicks "save", the method <code>saveWorkOrder()</code> is called. Inside, I am trying to use the method <code>setWrappedData()</code> on a <code>DataModel</code> variable, after I create the result using the <code>EntityManagers</code>s <code>createNamedQuery()</code>:</p>

<pre><code>public String saveWorkOrder() {
    try {
        utx.begin();
        workOrderCurrent = em.merge(workOrderCurrent);
        em.persist(workOrderCurrent);
        List&lt;WorkOrder&gt; resultList = em.createNamedQuery("SelectWorkOrders").getResultList();
        workOrdersList.setWrappedData(resultList);
        utx.commit();
    } catch (NotSupportedException e) {
        e.printStackTrace();
    } catch (SystemException e) {
        e.printStackTrace();
    } catch (SecurityException e) {
        e.printStackTrace();
    } catch (IllegalStateException e) {
        e.printStackTrace();
    } catch (RollbackException e) {
        e.printStackTrace();
    } catch (HeuristicMixedException e) {
        e.printStackTrace();
    } catch (HeuristicRollbackException e) {
        e.printStackTrace();
    }
    return "rainErosion";
}
</code></pre>

<p>Unfortunately I am getting a <code>NullPointerException</code> in <code>setWrappedData(resultList)</code> although <code>resultList</code> contains one element (with the actual user input) and is not pointing to <code>Null</code>, so normaly this shouldn't happen.</p>

<p>Does anyone know, why this happens?</p>