PrimeFaces p:calendar with readonlyInput =" true"重置按钮不产生AJAX请求 [英] PrimeFaces p:calendar with readonlyInput="true" reset button causing no AJAX request
问题描述
由于< p:calendar>
(readonlyInput =true)没有属性/选项将值重置为null,所以目前最好的解决方案是请使用某些客户端JS重置值,如下所示:
http:// stackoverflow.com/a/12325640/396732
但是,一旦清除按钮控制了AJAX按钮,
我尝试处理结束日期按钮,例如:
< p:calendar id =end-date
widgetVar =myEntityEndDate
value =#{myEntityManager.selectedEndDate}
readonlyInput = true
showOn =button>
<! - update dependentbegincalendar component: - >
< p:ajax event =dateSelectprocess =@ thisupdate =begin-date/>
< / p:calendar>
< p:commandButton icon =ui-icon ui-icon-close
onclick =myEntityEndDate.setDate(null);
process =end-date
update =begin-date end-date/>
但它不工作...
问:
如何为 AJAXed p:calendar组件实施重置按钮? / p>
附录:
此处提出相同的问题: http://forum.primefaces.org/viewtopic.php?f=3&t=27821 。看起来jQuery可能是有罪党。
如果您希望重置将反映在服务器上,您应该使用
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;
}
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:
http://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.
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;
}
这篇关于PrimeFaces p:calendar with readonlyInput =" true"重置按钮不产生AJAX请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!