<div class="card">
<p:messages showDetail="true"/>
<h2>reCAPTCHA (API key is valid)</h2>
<h:form>
<p:captcha label="reCaptcha" type="g-recaptcha"/>
<br/>
<p:commandButton value="Check reCaptcha" action="#{captchaView.submit}" ajax="false" icon="pi pi-check"/>
</h:form>
<h2>hCaptcha (API key is invalid)</h2>
<h:form>
<p:captcha label="hCaptcha" type="h-captcha"/>
<br/>
<p:commandButton value="Check hCaptcha" action="#{captchaView.submit}" ajax="false" icon="pi pi-check"/>
</h:form>
</div>
package org.primefaces.showcase.view.misc;
import jakarta.enterprise.context.RequestScoped;
import jakarta.faces.application.FacesMessage;
import jakarta.faces.context.FacesContext;
import jakarta.inject.Named;
import io.quarkus.runtime.annotations.RegisterForReflection;
@Named
@RequestScoped
@RegisterForReflection(serialization = true)
public class CaptchaView {
public void submit() {
FacesMessage msg = new FacesMessage(FacesMessage.SEVERITY_INFO, "Correct", "Correct");
FacesContext.getCurrentInstance().addMessage(null, msg);
}
}