null value on DateTimePicker

323 Views Asked by At

I have this JSF (bootsfaces) page:

    <h:panelGroup layout="block" id="my-panel">
      <p:outputLabel value="dal" for="myDatepicker" />
      <b:dateTimePicker format="DD/MM/YYYY" locale="it"
        value="#{myBean.myForm.date}"
        id="myDatepicker" render-label="false"
        maxDate="moment().format()" useCurrent="false">
        <f:validator validatorId="dateConverterValidator" />
        <p:ajax update="my-panel" event="change" immediate="true" />
      </b:dateTimePicker>

      <p:commandButton
        value="#{messages['label.date']}"
        update="my-panel" process="@this my-panel"
        action="#{myBean.myForm.AddDate}"
        look="primary">
      </p:commandButton>
    </h:panelGroup>

When I hit the commandButton the values of the other inputText are correctly set, but the datepicker value it's always null.

Here's my myForm class:

    public class MyForm {

      private Date dtIscrOrdine;

      //getters and setters

      public void addDate(){
      if(date != null){
        service.add(date);
      }
    }
1

There are 1 best solutions below

0
On

Maybe you are not using the component correctly.

The BootsFaces documentation recommends using the "blur" event on ajax. BootsFaces DateTimePicker documentation

Check with a breakpoint in the date setter.

<p:ajax update="my-panel" event="blur"/>