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

蹲街弑〆低调 提交于 2020-01-06 08:16:34

问题


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.


回答1:


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;
}


来源:https://stackoverflow.com/questions/14235357/primefaces-pcalendar-with-readonlyinput-true-reset-button-causing-no-ajax-req

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!