ReCaptcha meets JSF

PrimeFaces provides a captcha component based upon popular api reCaptcha. The component is actually an input component and has a built-in CaptchaValidator, this allows to integrate the reCaptcha well to JSF lifecycle since an invalid answer would cause a ValidatorException.


Getting started with captcha;

1. Sign up for keys
reCaptcha is a webservice and you need two keys in order to communicate with their verify server.
You can sign up and get these keys for domain. The link is :

2. Add your private key in web.xml
RecaptchaValidator needs the private key when verifying the answer, for security reasons this is not set on the components
as an attribute but as a context param in web.xml


3. Add captcha to your JSF form
That’s it, now you can use captcha on the form you need to make sure the entity who submits the form is a human:)

<p:captcha publicKey="your-public-key"/>

4. Configuration
Multiple languages and themes are also supported, following is a Turkish captcha with different theme.

<p:captcha theme="white" language="tr" publicKey="your-public-key"/>

Online Demo
You can check out the captcha examples online.

Note that captcha component is added after 0.8.0 release and is currently in 0.8.1-SNAPSHOT of PrimeFaces as a beta component.


6 Responses to ReCaptcha meets JSF

  1. I tried but it failed to show the page.. 😦

    com.sun.facelets.tag.TagException: /pages/security/login.xhtml @61,70 Tag Library supports namespace:, but no tag was defined for name: captcha
    at com.sun.facelets.compiler.CompilationManager.pushTag(

    questions: does it also works together richfaces ? I just added the primefaces lib to my lib folder, configured the tags and launched..

    my snapshot demo is here:

  2. cagataycivici says:

    Hi Felipe,

    I’ve tested PrimeFaces with RichFaces, they do fine together, even combining ajax stuff works fine. So no known problem on that part.

    Captcha components is added after 0.8.0 so it’s not in the jar you’re using, if you try a 0.8.1-SNAPSHOT(build from source, no nightly builds yet) it’ll work.

  3. no luck 😦

    I tried:

    Prime Technology Maven Repository



    Try downloading the file manually from the project website.

  4. cagataycivici says:

    0.8.1 Snapshots were not available in prime repo so it’s normal that maven can’t find it. However I’ve just deployed the latest snapshot. Could you please try again? Also we’re planning to set the stuff to publish nightly builds soon.

  5. cagataycivici says:

    One more thing, PrimeFaces support forum is the best way to ask for help in cases like this:)

%d bloggers like this: