Captcha is based on reCAPTCHA API.
<div class="card">
<h:form>
<p:messages showDetail="true"/>
<p:captcha label="Captcha"/>
<br/>
<p:commandButton value="Check" 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);
}
}