问题描述
我尝试通过这种方式将质数日历与弹出窗口配合使用:
I'm try to use the primefaces calendar with popup in this way:
<p:calendar pattern="yyyy-MMM-dd" value="#{controller.beginDate}" mask="true" navigator="true">
<f:ajax event="valueChange" listener="#{controller.onChange}" />
</p:calendar>
这是相对的控制器:
@ManagedBean
public class Controller {
private Date beginDate;
public Date getBeginDate() {
return beginDate;
}
public void setBeginDate(Date beginDate) {
this.beginDate = beginDate;
}
public void onChange() {
// do somethings
}
}
问题:如果我在输入字段中更改了值,则该事件将被执行,但是如果我从弹出窗口中对其进行更改,则该事件将不会执行.
The problem: if I change the value from the input field, the event will be execute, but if I change it from the popup, the event will NOT execute.
有人可以帮助我吗?
推荐答案
valueChange
事件仅由HTML DOM change
事件触发.当使用JavaScript手段操纵输入值时,确实不会触发此操作.
The valueChange
event is only triggered by HTML DOM change
event. This is indeed not triggered when the input value is manipulated by JavaScript means.
您需要使用dateSelect
事件.而且,在PrimeFaces组件中,最好使用<p:ajax>
而不是<f:ajax>
.
You need the dateSelect
event instead. And, in PrimeFaces components, you'd better use <p:ajax>
instead of <f:ajax>
.
<p:calendar ...>
<p:ajax event="valueChange" listener="#{controller.onChange()}" />
<p:ajax event="dateSelect" listener="#{controller.onChange()}" />
</p:calendar>
另请参见:
- PrimeFaces用户指南
- PrimeFaces Users Guide
See also:
这篇关于Primefaces 5.1日历弹出窗口不执行valueChange事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!