1
votes

In BootStrap calling a backend bean via AJAX does not seem to work for the DateTimePicker component.

If I am wrong with my code, could anybody please help?

To my surprise also the DateTimePicker reference page of BootStrap does not work with AJAX. On the reference page (https://showcase.bootsfaces.net/forms/DateTimePicker.jsf)

the reference code

<b:form>
  <b:dateTimePicker value="#{test.dataToPick}" ondtchange="ajax:test.updateTestField()" process="@this" update="@next" label="Select date:" iconAwesome="bolt" />
  <b:inputText value="#{test.testField}" label="Result: " readonly="true" />
</b:form>

is also not working.

Here is my code that is not working:

<b:form>
<b:dateTimePicker value="#{listBean.editMonth}"
    readonly="false"
    allow-input-toggle="false"
    icon-position="right"
    mode="popup"
    format="MMM YYYY"
    side-by-side="false"
    show-date="true"
    show-time="false"
    show-icon="true"
    required="true"
    viewMode="months"
    locale="en"
    iconSize="xs"
    styleClass="datePicker"
    id="monthpicker"
    process="@this"
    ondtchange="ajax:listTradesBean.updateMonth()"
    onblur="ajax:listTradesBean.updateMonth()"/>
</b:form>

Normally I would expect that the backend code "updateMonth()" would be called. The java code snippet for the backend bean simply is:

public void updateMonth() {
    System.out.println("WORKING!");     
}

Other methods within this backend bean are called without problems using AJAX.

1

1 Answers

0
votes

You are right, the example in the Bootsfaces showcase page does not work.

Strangely enough, I managed to build a working example that solves your problem by using the traditional JSF AJAX (legacy) syntax:

<b:dateTimePicker id="datePicker"
    format="DD/MM/YYYY HH:mm"
    value="#{testBB.selectedDate}"
    required="true"
    renderLabel="false"
    ajax="true"
    process="@this"
    update="@this"
    ondtchange="#{testBB.doSomething()}">
</b:dateTimePicker>

As far as I know, this will work the same way as "ajax:testBB.doSomething()".