What is CAPTCHA
A CAPTCHA is a program that protects websites against bots by generating and grading tests that humans can pass but current computer programs cannot. For example, humans can read distorted text as the one shown below, but current computer programs can't
What is reCAPTCHA
reCAPTCHA is a free CAPTCHA service that helps to digitize books, newspapers and old time radio shows. For more information see the reCAPTCHA website.
Here is a sample of a reCAPTCHA image on a website.
- Register your domain with the reCAPTCHA website.
- Download the Java library from here.
- Download the Div.java and ReCaptchaField.java.
- Add the following code into your click form.
ReCaptchaField reCaptchaField = new ReCaptchaField("captcha", YOUR_CAPTCHA_PUBLIC_KEY, YOUR_CAPTCHA_PRIVATE_KEY, ReCaptchaField.THEME_CLEAN);
Add to form
Div reCaptchaHolder = new Div(); reCaptchaHolder.add(reCaptchaField); form.add(reCaptchaHolder);
Click 2.3.0 has made some changes. So I updated ReCaptchaField to make it work with 2.3.0
Here is two things that I have done.
1. Import lib from apache instead of sf
2. onProcess method will only process field if it participated in the incoming request which in this case does not call the validate() method. So I override the onProcess method.
ReCaptchaField.java for Click 2.3