ajax操作忽略了Recaptcha
我使用的是Primefaces,但是我不能使用它们的p:captcha组件,因为它不能由Ajax呈现/更新。ajax操作忽略了Recaptcha,ajax,jsf-2,primefaces,recaptcha,Ajax,Jsf 2,Primefaces,Recaptcha,我使用的是Primefaces,但是我不能使用它们的p:captcha组件,因为它不能由Ajax呈现/更新。 因此,我尝试使用reCaptcha的AJAXAPI,通过使用reCaptcha.create在表单上动态创建它。代码如下: Recaptcha.create(/*public_code*/, 'captchadiv', { tabindex : 1,
因此,我尝试使用reCaptcha的AJAXAPI,通过使用reCaptcha.create在表单上动态创建它。代码如下:
Recaptcha.create(/*public_code*/,
'captchadiv', {
tabindex : 1,
theme : "red",
callback : Recaptcha.focus_response_field
});
已经创建了Captcha,但它不会验证来自ajax按钮的操作,比如p:commandButton。我做错了什么
我使用的是Primefaces,但是我不能使用它们的p:captcha组件,因为它不能由Ajax呈现/更新
错。p:captcha
元素有一个id
属性,因此它可以使用AJAX更新。它还有一个rendered
属性,可以将其设置为true
或false
,即使在运行时也是如此
已经创建了Captcha,但它不会验证来自ajax按钮的操作,比如p:commandButton。我做错了什么
我猜您正在呈现的captcha元素没有与JSF/PrimeFaces集成
为什么不这样使用PrimeFaces验证码元素:
<div id="captchaWrapper">
<p:captcha rendered="captchaBean.rendered"/>
</div>
<p:commandButton value="render" action="#{captchaBean.render}"
update="captchaWrapper"/>
public class CaptchaBean
{
//Getter/setter omitted
private boolean rendered;
public void render()
{
rendered = true;
}
}