阿贾克斯valueChangeListener [英] Ajax for valueChangeListener
问题描述
我使用了号码:AJAX
监听器来处理值改变事件(因为<code> valueChangeListener 上的形式推出提交):
&LT;电话号码:AJAX事件=变监听器=#{bean.onNameChanged}/&GT;
处理方法:
公共无效onNameChanged(最终AjaxBehaviorEvent事件)
现在的问题是,我无法找到 AjaxBehaviorEvent
和它的类层次读旧值输入的地方。我不是能找到线索在谷歌,如何让旧值...
如何访问在 P中的旧值:AJAX的onChange
事件
的问题是,我找不到AjaxBehaviorEvent也没有了它的类层次结构读取输入的旧价值的地方。无论是我能找到的提示在谷歌,如何让旧值... 的
使用一个 valueChangeListener
。
很遗憾,valueChangeListener为p之前调用:AJAX,所以我没有从形式该方法的实际数据,所以理论上我可以用valueChangeListener记住原来的值,然后等待电话号码:阿贾克斯流程... 的
队列中的值更改事件调用应用程序阶段。
公共无效valueChangeListenerMethod(ValueChangeEvent事件){
如果(event.getPhaseId()!= PhaseId.INVOKE_APPLICATION){
event.setPhaseId(PhaseId.INVOKE_APPLICATION);
event.queue();
返回;
}
//这里做你原来的工作。
//它只会在目前的阶段ID是INVOKE_APPLICATION被调用。
}
I'm using the p:ajax
listener to handle value change events (because valueChangeListener
is launched on form submit):
<p:ajax event="change" listener="#{bean.onNameChanged}"/>
Handle method:
public void onNameChanged(final AjaxBehaviorEvent event)
The problem is, I can't find in AjaxBehaviorEvent
nor its class hierarchy the place to read the old value of the input. Neither could I find hint in google, how to get the old value...
How to access the old value in the p:ajax onChange
event?
The problem is, I can't find in AjaxBehaviorEvent nor its class hierarchy the place to read the old value of the input. Neither could I find hint in google, how to get the old value...
Use a valueChangeListener
.
Unfortunatelly, valueChangeListener is invoked before p:ajax, so I don't have actual data from forms in that method, so in theory I could use valueChangeListener to remember the old value and then wait for p:ajax to process...
Queue the value change event to the invoke application phase.
public void valueChangeListenerMethod(ValueChangeEvent event) {
if (event.getPhaseId() != PhaseId.INVOKE_APPLICATION) {
event.setPhaseId(PhaseId.INVOKE_APPLICATION);
event.queue();
return;
}
// Do your original job here.
// It will only be invoked when current phase ID is INVOKE_APPLICATION.
}
这篇关于阿贾克斯valueChangeListener的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!