org.opencms.frontend.templateone.form
Interface I_CmsField

All Known Implementing Classes:
A_CmsField, CmsCaptchaField, CmsCheckboxField, CmsEmailField, CmsEmptyField, CmsFileUploadField, CmsHiddenField, CmsPrivacyField, CmsRadioButtonField, CmsSelectionField, CmsTextareaField, CmsTextField

public interface I_CmsField

Defines the methods required for form fields.


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.
 java.lang.String getErrorMessage()
          Returns a optional, custom error message to be displayed instead of the standard validation error message.
 java.util.List getItems()
          Returns the list of items for select boxes, radio buttons and checkboxes.
 java.lang.String getLabel()
          Returns the description text of the input field.
 java.lang.String getName()
          Returns the name of the input field.
 int getPlaceholder()
          Returns the placeholder.
 int getPosition()
          Returns the position.
 java.lang.String getType()
          Returns the type of the input field, e.g.
 java.lang.String getValidationExpression()
          Returns the regular expression that is used for validation of the field.
 java.lang.String getValue()
          Returns the initial value of the field.
 boolean isMandatory()
          Returns if this input field is mandatory.
 boolean needsItems()
          Checks if an item list is needed for this field.
 void setPlaceholder(int placeholder)
          Sets the placeholder.
 void setPosition(int position)
          Sets the position.
 java.lang.String validate(CmsFormHandler formHandler)
          Validates this field by validating it's constraints and input value.
 

Method Detail

getItems

java.util.List getItems()
Returns the list of items for select boxes, radio buttons and checkboxes.

The list contains CmsFieldItem objects with the following information:

  1. the value of the item
  2. the description of the item
  3. the selection of the item (true or false)

Returns:
the list of items for select boxes, radio buttons and checkboxes

getLabel

java.lang.String getLabel()
Returns the description text of the input field.

Returns:
the description text of the input field

getName

java.lang.String getName()
Returns the name of the input field.

Returns:
the name of the input field

getType

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

Returns:
the type of the input field

getValidationExpression

java.lang.String getValidationExpression()
Returns the regular expression that is used for validation of the field.

Returns:
the regular expression that is used for validation of the field

getValue

java.lang.String getValue()
Returns the initial value of the field.

Returns:
the initial value of the field

getErrorMessage

java.lang.String getErrorMessage()
Returns a optional, custom error message to be displayed instead of the standard validation error message.

Returns:
a custom error message for validation errors, or null

isMandatory

boolean isMandatory()
Returns if this input field is mandatory.

Returns:
true if this input field is mandatory, otherwise false

needsItems

boolean needsItems()
Checks if an item list is needed for this field.

Returns:
true if an item list is needed for this field, otherwise false

validate

java.lang.String validate(CmsFormHandler formHandler)
Validates this field by validating it's constraints and input value.

Parameters:
formHandler - the handler of the current form
Returns:
null in case of no error, CmsFormHandler.ERROR_VALIDATION if validation of the input value failed, CmsFormHandler.ERROR_VALIDATION if validation of the input value failed

buildHtml

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.

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

getPlaceholder

int getPlaceholder()
Returns the placeholder.

Returns:
the placeholder

setPlaceholder

void setPlaceholder(int placeholder)
Sets the placeholder.

Parameters:
placeholder - the placeholder to set

getPosition

int getPosition()
Returns the position.

Returns:
the position

setPosition

void setPosition(int position)
Sets the position.

Parameters:
position - the position to set