title: How to set JSF input field value before submit
body: <p>I a have a JSF page with PrimeFaces with some input fields. Before a submit is done, I would like to use the value of a field as input for a method which does some calculations and updates another field with the result but without submitting the form. </p>
  
  <p>This is the field that will be used as input for my method:</p>
  
  <pre><code>&lt;h:outputLabel for="hiredate" value="#{msgs['addUser.hireDate']}" /&gt;
                                  &lt;p:calendar id="hiredate" value="#{userWizardMB.user.hireDate}" required="true" immediate="true"/&gt;
                                  &lt;p:message for="hiredate" /&gt;
  </code></pre>
  
  <p>The calculation is done by clicking a <code>&lt;p:commandButton&gt;</code>:</p>
  
  <pre><code>&lt;p:commandButton value="Calculate days" icon="ui-icon-circle-check" action="#{userWizardMB.calculateVacationDays}" update="vacationDays" process="@this" immediate="true"/&gt;
  </code></pre>
  
  <p>And this is the method called:</p>
  
  <pre><code>public void calculateVacationDays() {
          user.setVacationDays((int) vacationDaysCalculator
                  .calculateWithHireDate(user.getHireDate()));
  }
  </code></pre>
  
  <p>When debugging, though, I see that this field is NULL even if I set value in the form. </p>
  
  <p>How can I force the setting of this field - user.hireDate because I really need this value for my calculation?</p>
  
  <p>Thank you</p>
  
  <p><strong>Edit:</strong> I removed all of the other fields in the form and the immediate attribute:</p>
  
  <pre><code>&lt;h:form id="addUserForm"&gt;
      &lt;p:wizard widgetVar="wizard" flowListener="#{userWizardMB.onFlowProcess}"&gt;
                  &lt;!-- TAB FOR PERSONAL DATA --&gt;
                      &lt;p:tab id="personal" title="#{msgs['addUser.personalTab']}"&gt;
                          &lt;p:panel header="#{msgs['addUser.personalInformation']}"&gt;
                              &lt;p:message for="vacationDays" showDetail="true" autoUpdate="true" closable="true"/&gt;
                              &lt;h:panelGrid columns="3" columnClasses="label, value" styleClass="grid"&gt;
  
                                  &lt;h:outputLabel for="hiredate" value="#{msgs['addUser.hireDate']}" /&gt;
                                  &lt;p:calendar id="hiredate" value="#{userWizardMB.user.hireDate}" required="true" /&gt;
                                  &lt;p:message for="hiredate" /&gt;
  
  
                                  &lt;h:outputLabel for="vacationDays" value="#{msgs['addUser.vacationDays']}"/&gt;
                                  &lt;p:inputText id="vacationDays" value="#{userWizardMB.user.vacationDays}"/&gt;
                                  &lt;p:commandButton value="Calculate days" icon="ui-icon-circle-check" action="#{userWizardMB.calculateVacationDays}"  process="@this hiredate" update="vacationDays"/&gt;
                  &lt;/h:panelGrid&gt;
              &lt;/p:panel&gt;
          &lt;/p:tab&gt;
      &lt;/p:wizard&gt;
  &lt;/h:form&gt;
  </code></pre>
  
  <p>And the backing bean method is still not called.</p>