Kawu
Kawu

Reputation: 14003

PrimeFaces p:calendar with readonlyInput="true" reset button causing no AJAX request

Since there's no attribute/option for <p:calendar> (readonlyInput="true") to reset the value to null, the best available solution currently is to use some client JS to reset the value like here:

https://stackoverflow.com/a/12325640/396732

However, as soon as the clear button controls an AJAX button, the new calendar value isn't submitted.

I tried to process the end-date button, like:

                <p:calendar id="end-date"
                            widgetVar="myEntityEndDate"
                            value="#{myEntityManager.selectedEndDate}"
                            readonlyInput="true"
                            showOn="button">
                    <!-- update dependent "begin" calendar component: -->
                    <p:ajax event="dateSelect" process="@this" update="begin-date" />
                </p:calendar>
                <p:commandButton icon="ui-icon ui-icon-close"
                                 onclick="myEntityEndDate.setDate(null);"
                                 process="end-date"
                                 update="begin-date end-date" />

However it isn't working...

Q:

How do you implement a reset button for an AJAXed p:calendar component?

Addendum:

The same question was asked here: http://forum.primefaces.org/viewtopic.php?f=3&t=27821 . It seems like jQuery could be the "guilty party". Anyways, it should be solved/solvable IMHO.

Upvotes: 1

Views: 7168

Answers (1)

Daniel
Daniel

Reputation: 37071

If you want the reset will be reflected on the server you should use the action of p:commandButton

<p:commandButton icon="ui-icon ui-icon-close"
    action="#{myEntityManager.resetDate}"
    process="end-date"
    update="begin-date end-date" />


public void resetDate(){
    selectedEndDate = null;
}

Upvotes: 1

Related Questions