Primary Captcha disappears or is not updated / updated with invalid input?

I have the following code snippet inside h:form

<h:panelGrid id="captchaGrid">
    <p:captcha id="captcha" label="Captcha" required="true"
        requiredMessage="required"
        validatorMessage="...">
    </p:captcha>
    <p:message id="captchaMessage" for="captcha" />
</h:panelGrid>

<p:commandButton id="submitButton" value="save"
    actionListener="#{userBean.save}" update="captchaGrid"
    onstart="doSomething()"
    oncomplete="doSomethingElse(xhr, status, args)" icon="ui-icon-check">
</p:commandButton>

This works fine if I enter the code correctly. However, if I enter an invalid value, the captcha component will simply disappear.

I tried to remove the attribute update="captchaGrid". This time the captcha has not disappeared. Instead, it was not updated visually, but (I think) internally. Since the correct completion of two words still raises a validation error.

Further; I do not want to use ajax="false".

Update: I also tried oncomplete="Recaptcha.reload()". Does not work. There is a mistake. But I do not know if it was my code or Primefaces 3.0 :)

2: maple_shaft, , Primefaces/Recaptcha. , .

.

+5
4

, .

Issue 1642 " ​​".

Primefaces Captcha Recaptcha, Ajax. , . , Captcha , Ajax , " " "".

: , , captcha <iframe> , . , .

+7

, "captcha on on". ....

  <p:dialog widgetVar="captchaDlgWar" modal="true" closable="false" resizable="false"
              header="Prove you are human..." width="350" height="200">

        <h:form>
            <h:panelGrid columns="1">

                <p:captcha label="Captcha"
                           id="captchaId"
                           language="tr"
                           theme="white"
                           required="true"
                           requiredMessage="Please Enter Capcha Text"
                           validatorMessage="Captcha text does not match."/>
                <p:commandButton id="btnContinue"
                                 ajax="false"
                                 value="Continue"
                                 actionListener="#{MyBean.onButtonAction}"/>

            </h:panelGrid>
        </h:form>
    </p:dialog>

MyBean ------- >

public void onButtonAction(ActionEvent e) {
   RequestContext.getCurrentInstance().execute("captchaDlgWar.hide()");
   //Do your stuff
}
+3

@user2393398.

p:captcha, p:ajaxStatus, .

<h:form style="width: 400px;" >
    <h:outputText value="Informe seu CPF/CNPJ ou E-mail abaixo, e um e-mail de recuperação será enviado para seu endereço." />
    <br /><br />
    <p:messages id="messageGlobal" globalOnly="true" />
    <h:panelGrid columns="3" cellspacing="5" >
        <h:outputLabel for="inputUsuarioRecuperacao" value="CPF/CNPJ ou E-mail: " style="float: right;"/>    
        <p:inputText id="inputUsuarioRecuperacao" value="#{loginController.usuario}" required="true" size="30" />
        <p:message id="messageUsuarioRecuperacao" for="inputUsuarioRecuperacao" display="icon" />
        <p:spacer />
        <p:captcha id="inputCaptcha" theme="white" secure="true" validatorMessage="Os caracteres inseridos não correspondem à verificação de palavras. Tente novamente." />
        <p:message id="messageCaptcha" for="inputCaptcha" display="icon" />
        <p:spacer />
        <p:commandButton value="Enviar" actionListener="#{loginController.enviarEmailRecuperarSenha()}" update="messageGlobal messageCaptcha messageUsuarioRecuperacao" />
    </h:panelGrid>
    <p:ajaxStatus onsuccess="Recaptcha.reload();" />
</h:form> 
+2

I did not find a way to reload the captcha, so I have to reload it in case of oncomplete or onerror using JavaScript.

Recaptcha.reload();

Maybe this will work for you.

0
source

All Articles