1
votes

I've got a form with two primefaces calendar input elements and a datatable on it. The calendar items are used to filter the result displayed in the table as from to values. Therefore I use an p:ajax ‘dateSelect’ event which is working fine when doing the manipulation with the mouse over the popup. But when I change the date manually in the input field with the keybord no change event is fired. When I use a second p:ajax event for blur or change I'm not able to get the new value.

    <p:calendar id="startDate"
                value="#{filterStart}" 
                required="true"
                showOn="button" 
                maxdate="#{filterEnd}"
                >
        <p:ajax event="dateSelect"
                listener="#{listController.onFilterStartChanged}"
                update="filterTbl, endDate" />
        <p:ajax event="change" 
                listener="#{listController.onFilterStartBlured}"
                update="filterTbl, endDate"
                process="@this"
                partialSubmit="true" immediate="true"  />                                                                       
</p:calendar>

the method onFilterStartChanged gets called when selection is made over the pupup it's possible to read the new value:

public void onFilterStartChanged(final SelectEvent event)  {...}

but the Keyboard changes are not fired when moving Focus to another component

public void onFilterStartBlured(final AjaxBehaviorEvent event)  {
    Date newDate = (Date)((Calendar)event.getSource()).getValue();
    ...
}

how can I get the new date?

1

1 Answers

0
votes

I have same need with p:calendar in Primefaces 5.3 and it's work for me whit this code. I don't use event parameter

<p:calendar id="startDate"
            value="#{filterStart}" 
            required="true"
            showOn="button" 
            maxdate="#{filterEnd}">
    <p:ajax event="dateSelect"
            listener="#{listController.onFilterStartChanged()}"
            update="filterTbl, endDate" />
    <p:ajax event="change" 
            listener="#{listController.onFilterStartChanged()}"
            update="filterTbl, endDate" />
</p:calendar>

no parameter in the method, value is in filterStart

public void onFilterStartChanged()  {...}