title: How do I force a Primefaces calendar to update after a change Ajax event validates the new value?
body: <p>I'm modifying a page with two Calendar components, to select a start date and an end date. I'm supposed to make them check that the start date is before the end date whenever you modify either of them; if the start is set after the end or viceversa, the code changes the end date to the maximum date and pops a warning.</p>
  
  <p>The event listeners run correctly, but the end date calendar fails to update to reflect the new value; it's not that it updates before the listener changes the value ─it fails to update at all.</p>
  
  <p>The project runs on Primefaces 5.3 and Java 1.6. This is the xhtml (minus styles for readability):</p>
  
  <pre><code>&lt;p:outputPanel id="fl83"&gt;
      &lt;p:outputPanel id="fl83c3"&gt;
          &lt;h:outputLabel value="Start date" for="fechaInicioMP" /&gt;
          &lt;p:calendar locale="es" pattern="dd/MM/yyyy" id="fechaInicioMP"
              maxdate="#{filtroFechasBB.fechaMaxFin}" value="#{filtroFechasBB.fechaInicio}"
              onSelectUpdate=":f183" &gt;
              &lt;p:ajax event="blur" /&gt;
              &lt;f:ajax event="change" listener="#{filtroFechasBB.fechaInicioTextChange}"
                  render="@this" update="@form" /&gt;
              &lt;p:ajax event="dateSelect" listener="#{filtroFechasBB.fechaInicioClickChange}"
                  update="@form" /&gt;
          &lt;/p:calendar&gt;
      &lt;/p:outputPanel&gt;
      &lt;p:outputPanel id="fl83c4"&gt;
          &lt;h:outputLabel value="End date" for="fechaFinMP" /&gt;
          &lt;p:calendar locale="es" pattern="dd/MM/yyyy" id="fechaFinMP"
              maxdate="#{filtroFechasBB.fechaMaxFin}" value="#{filtroFechasBB.fechaFin}"
              onSelectUpdate=":f183" &gt;
              &lt;p:ajax event="blur" /&gt;
              &lt;f:ajax event="change" listener="#{filtroFechasBB.fechaFinTextChange}"
                  render="@this" update=":fl83" /&gt;
              &lt;p:ajax event="dateSelect" listener="#{filtroFechasBB.fechaFinClickChange}"
                  update=":fl83" /&gt;
          &lt;/p:calendar&gt;
      &lt;/p:outputPanel&gt;
  &lt;/p:outputPanel&gt;
  </code></pre>
  
  <p>And these are the listeners:</p>
  
  <pre><code>    public void fechaFinTextChange() {
      if(fechaFin.after(fechaMaxFin)) {
          fechaFin = fechaMaxFin;
          addErrorMessage(FFIN_AFTER_FMAX);
      }
      compareInicioBeforeFin();
  }
  
  public void fechaFinClickChange(SelectEvent event) {
      setFechaFin((Date)event.getObject()); // I couldn't find out why this is here given that
                                            // the setter has already been called
      compareInicioBeforeFin();
      if (updateMetodoEntreBB != null) {
          ajaxActualiza(event, OpcionesAjax.F_FIN);
      }
  }
  
  // fechaInicioTextChange and fechaInicioClickChange do pretty much the same as these two
  
  private void compareInicioBeforeFin() {
      if(fechaInicio.after(fechaFin)) {
          fechaFin = fechaMaxFin;
          addErrorMessage(FINI_AFTER_FFIN);
      }
  }
  </code></pre>
  
  <p>There are two Ajax events because the JSF change event doesn't trigger when you click on the calendar and the PrimeFaces dateSelect doesn't trigger when you type a date in.</p>
  
  <p>I've tried the onSelectUpdate from the calendar and the render and update from both ajax events, setting them to @this, @form, the end date calendar's ID, both calendars' IDs, the calendar's outputPanel's ID and the common outputPanel's ID, and the damn calendars <em>just. Won't Update.</em></p>
  
  <p>I'm at my wits' end and my Google Fu doesn't find any solution that works either.</p>