0

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);
      }
    }
  • Hi, Plain JSF has no dateTimePicker... Please tag the question with the component framework you use – Kukeltje Jul 13 '20 at 13:26
  • 1
    [mcve] please (and version info) and read all in https://stackoverflow.com/questions/2118656/commandbutton-commandlink-ajax-action-listener-method-not-invoked-or-input-value – Kukeltje Jul 13 '20 at 13:30
  • The method is invoked, but the values (just of datetimepicker) are null. – Salvatore Maruccio Jul 13 '20 at 13:47
  • Read the SO question @Kukeltje linked. You are probably running into a validation error because. Also, check your date format. It does not look right. – Jasper de Vries Jul 13 '20 at 15:20

1 Answers1

0

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"/>