org.opencms.frontend.templateone.form
Class CmsCaptchaField

java.lang.Object
  extended by org.opencms.frontend.templateone.form.A_CmsField
      extended by org.opencms.frontend.templateone.form.CmsCaptchaField
All Implemented Interfaces:
I_CmsField

public class CmsCaptchaField
extends A_CmsField

Creates captcha images and validates the pharses submitted by a request parameter.


Field Summary
static java.lang.String C_PARAM_CAPTCHA_PHRASE
          Request parameter name of the captcha phrase.
 
Constructor Summary
CmsCaptchaField(CmsCaptchaSettings captchaSettings, java.lang.String fieldLabel, java.lang.String fieldValue)
          Creates a new captcha field.
 
Method Summary
 java.lang.String buildHtml(CmsFormHandler formHandler, org.opencms.i18n.CmsMessages messages, java.lang.String errorKey)
          Builds the HTML input element for this element to be used in a frontend JSP.
 CmsCaptchaSettings getCaptchaSettings()
          Returns the captcha settings of this field.
static java.lang.String getStaticType()
          Returns the type of the input field, e.g.
 java.lang.String getType()
          Returns the type of the input field, e.g.
 boolean validateCaptchaPhrase(org.opencms.jsp.CmsJspActionElement jsp, java.lang.String captchaPhrase)
          Validates the captcha phrase entered by the user.
 void writeCaptchaImage(org.opencms.jsp.CmsJspActionElement cms)
          Writes a Captcha JPEG image to the servlet response output stream.
 
Methods inherited from class org.opencms.frontend.templateone.form.A_CmsField
getErrorMessage, getItems, getLabel, getName, getPlaceholder, getPosition, getValidationExpression, getValue, incrementPlaceholder, isMandatory, needsItems, setErrorMessage, setItems, setLabel, setMandatory, setName, setPlaceholder, setPosition, setValidationExpression, setValue, showRowEnd, showRowStart, toString, validate, validateConstraints, validateValue
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

C_PARAM_CAPTCHA_PHRASE

public static final java.lang.String C_PARAM_CAPTCHA_PHRASE
Request parameter name of the captcha phrase.

See Also:
Constant Field Values
Constructor Detail

CmsCaptchaField

public CmsCaptchaField(CmsCaptchaSettings captchaSettings,
                       java.lang.String fieldLabel,
                       java.lang.String fieldValue)
Creates a new captcha field.

Parameters:
captchaSettings - the settings to render captcha images
fieldLabel - the localized label of this field
fieldValue - the submitted value of this field
Method Detail

getStaticType

public static java.lang.String getStaticType()
Returns the type of the input field, e.g. "text" or "select".

Returns:
the type of the input field

buildHtml

public java.lang.String buildHtml(CmsFormHandler formHandler,
                                  org.opencms.i18n.CmsMessages messages,
                                  java.lang.String errorKey)
Description copied from interface: I_CmsField
Builds the HTML input element for this element to be used in a frontend JSP.

Parameters:
formHandler - the handler of the current form
messages - a resource bundle containing HTML snippets to build the HTML element
errorKey - the key of the current error message
Returns:
the HTML input element for this element to be used in a frontend JSP
See Also:
I_CmsField.buildHtml(CmsFormHandler, org.opencms.i18n.CmsMessages, String)

getCaptchaSettings

public CmsCaptchaSettings getCaptchaSettings()
Returns the captcha settings of this field.

Returns:
the captcha settings of this field

getType

public java.lang.String getType()
Description copied from interface: I_CmsField
Returns the type of the input field, e.g. "text" or "select".

Returns:
the type of the input field
See Also:
I_CmsField.getType()

validateCaptchaPhrase

public boolean validateCaptchaPhrase(org.opencms.jsp.CmsJspActionElement jsp,
                                     java.lang.String captchaPhrase)
Validates the captcha phrase entered by the user.

Parameters:
jsp - the Cms JSP
captchaPhrase - the captcha phrase to be validate
Returns:
true, if the captcha phrase entered by the user is correct, false otherwise

writeCaptchaImage

public void writeCaptchaImage(org.opencms.jsp.CmsJspActionElement cms)
                       throws java.io.IOException
Writes a Captcha JPEG image to the servlet response output stream.

Parameters:
cms - an initialized Cms JSP action element
Throws:
java.io.IOException - if something goes wrong