0
votes

I've been trying to solve this issue but I can't get it solved. The issue is that I have a calendar with a dateSelect event ready to be fired whenever the user selects a date in the popup calendar, but the listener is never executed. Syntax is correct from my point of view.

form.xhtml calendar code.

                        <p:calendar value="#{travel.departureDate}" required="true"
                            id="departureDate" pattern="MM/dd/yyyy HH:mm:ss"
                            onfocus="$('#ui-datepicker-div td').unbind();" readonly="true">
                            <p:ajax event="dateSelect" actionListener="#{travelControl.alterDate}"
                            update=":main-form:departureDate" />
                        </p:calendar>

Everything is inside a form and a panelGrid container.

The bean method is the following one.

public void alterDate(SelectEvent event) {
    System.out.println("Hour [Pre] "
            + travel.getDepartureDate().toString()); //debug

    travel.setDepartureDate((Date) event.getObject());

    System.out.println("Hour [Post] "
            + travel.getDepartureDate().toString()); //debug
}

Once the date is selected, the value of the text field changes for a moment and then resets to the one in the bean as it wasn't changed due to the event not being properly fired.

1

1 Answers

1
votes

Use listener instead of actionListener:

listener ="#{travelControl.alterDate}"