Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jsf-2/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
ajax操作忽略了Recaptcha_Ajax_Jsf 2_Primefaces_Recaptcha - Fatal编程技术网

ajax操作忽略了Recaptcha

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,

我使用的是Primefaces,但是我不能使用它们的p:captcha组件,因为它不能由Ajax呈现/更新。
因此,我尝试使用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;
    }
}