primefaces inputText 不能与 ajax 事件一起使用
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16989728/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
primefaces inputText desn't work with ajax event
提问by Java Player
i used ajax <f:ajax>with primefaces inputText to fire specific action onBlur event but it doesn't, i tried also <p:ajax>but it deosn't work too!
我使用 ajax<f:ajax>和 primefaces inputText 来触发 onBlur 事件的特定操作,但它没有,我也尝试过,<p:ajax>但它也不起作用!
<p:inputText id="Name" value="#{personBean.missingName}"
label="Name" required="true" size="30"
validatorMessage="Name is required" >
<f:ajax event="blur" listener="#{personBean.validateName}"/>
</p:inputText>
action method inside personBean:
personBean 中的 action 方法:
public void validateName(){
System.err.println("OnBlur Action");
}
when the focus is lost from the inputText the inputTextdoesn't printed to the console
当 inputText 失去焦点时,inputText不会打印到控制台
回答by Alexandre Lavoie
Don't use f:ajaxwith PrimeFaces components. Also your method is not defined correclty.
不要f:ajax与 PrimeFaces 组件一起使用。此外,您的方法未定义正确性。
<p:inputText id="Name" value="#{personBean.missingName}"
label="Name" required="true" size="30"
validatorMessage="Name is required" >
<p:ajax event="blur" listener="#{personBean.validateName}"/>
</p:inputText>
Corrected method :
修正方法:
public void validateName(AjaxBehaviorEvent event){
System.err.println("OnBlur Action");
}
Note that you should use
请注意,您应该使用

