org.opencms.frontend.templateone.form
Class A_CmsField

java.lang.Object
  extended by org.opencms.frontend.templateone.form.A_CmsField
All Implemented Interfaces:
I_CmsField
Direct Known Subclasses:
CmsCaptchaField, CmsCheckboxField, CmsEmptyField, CmsFileUploadField, CmsHiddenField, CmsRadioButtonField, CmsSelectionField, CmsTextareaField, CmsTextField

public abstract class A_CmsField
extends java.lang.Object
implements I_CmsField

Abstract base class for all input fields.

Since:
6.0.0

Constructor Summary
A_CmsField()
          Default constructor.
 
Method Summary
 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 getValidationExpression()
          Returns the regular expression that is used for validation of the field.
 java.lang.String getValue()
          Returns the initial value of the field.
protected  void incrementPlaceholder(java.lang.String message)
          This function sets the cells of placeholder.
 boolean isMandatory()
          Returns if this input field is mandatory.
 boolean needsItems()
          Checks if an item list is needed for this field.
protected  void setErrorMessage(java.lang.String errorMessage)
          Sets the error message if validation failed.
protected  void setItems(java.util.List items)
          Sets the list of items for select boxes, radio buttons and checkboxes.
protected  void setLabel(java.lang.String description)
          Sets the description text of the input field.
protected  void setMandatory(boolean mandatory)
          Sets if this input field is mandatory.
protected  void setName(java.lang.String name)
          Sets the name of the input field.
 void setPlaceholder(int placeholder)
          Sets the placeholder.
 void setPosition(int position)
          Sets the position.
protected  void setValidationExpression(java.lang.String expression)
          Sets the regular expression that is used for validation of the field.
protected  void setValue(java.lang.String value)
          Sets the initial value of the field.
protected  boolean showRowEnd(java.lang.String colSizeTwo)
          This functions looks if the row should be end.
protected  boolean showRowStart(java.lang.String colSizeTwo)
          This functions looks if the row should be start.
 java.lang.String toString()
          Returns the field value as a String.
 java.lang.String validate(CmsFormHandler formHandler)
          Validates this field by validating it's constraints and input value.
protected  java.lang.String validateConstraints()
          Validates the constraints if this field is mandatory.
protected  java.lang.String validateValue()
          Validates the input value of this field.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.opencms.frontend.templateone.form.I_CmsField
buildHtml, getType
 

Constructor Detail

A_CmsField

public A_CmsField()
Default constructor.

Method Detail

getErrorMessage

public java.lang.String getErrorMessage()
Description copied from interface: I_CmsField
Returns a optional, custom error message to be displayed instead of the standard validation error message.

Specified by:
getErrorMessage in interface I_CmsField
Returns:
a custom error message for validation errors, or null
See Also:
I_CmsField.getErrorMessage()

getItems

public java.util.List getItems()
Description copied from interface: I_CmsField
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)

Specified by:
getItems in interface I_CmsField
Returns:
the list of items for select boxes, radio buttons and checkboxes
See Also:
I_CmsField.getItems()

getLabel

public java.lang.String getLabel()
Description copied from interface: I_CmsField
Returns the description text of the input field.

Specified by:
getLabel in interface I_CmsField
Returns:
the description text of the input field
See Also:
I_CmsField.getLabel()

getName

public java.lang.String getName()
Description copied from interface: I_CmsField
Returns the name of the input field.

Specified by:
getName in interface I_CmsField
Returns:
the name of the input field
See Also:
I_CmsField.getName()

getPlaceholder

public int getPlaceholder()
Returns the placeholder.

Specified by:
getPlaceholder in interface I_CmsField
Returns:
the placeholder

getPosition

public int getPosition()
Returns the position.

Specified by:
getPosition in interface I_CmsField
Returns:
the position

getValidationExpression

public java.lang.String getValidationExpression()
Description copied from interface: I_CmsField
Returns the regular expression that is used for validation of the field.

Specified by:
getValidationExpression in interface I_CmsField
Returns:
the regular expression that is used for validation of the field
See Also:
I_CmsField.getValidationExpression()

getValue

public java.lang.String getValue()
Description copied from interface: I_CmsField
Returns the initial value of the field.

Specified by:
getValue in interface I_CmsField
Returns:
the initial value of the field
See Also:
I_CmsField.getValue()

isMandatory

public boolean isMandatory()
Description copied from interface: I_CmsField
Returns if this input field is mandatory.

Specified by:
isMandatory in interface I_CmsField
Returns:
true if this input field is mandatory, otherwise false
See Also:
I_CmsField.isMandatory()

needsItems

public boolean needsItems()
Description copied from interface: I_CmsField
Checks if an item list is needed for this field.

Specified by:
needsItems in interface I_CmsField
Returns:
true if an item list is needed for this field, otherwise false
See Also:
I_CmsField.needsItems()

setPlaceholder

public void setPlaceholder(int placeholder)
Sets the placeholder.

Specified by:
setPlaceholder in interface I_CmsField
Parameters:
placeholder - the placeholder to set

setPosition

public void setPosition(int position)
Sets the position.

Specified by:
setPosition in interface I_CmsField
Parameters:
position - the position to set

toString

public java.lang.String toString()
Returns the field value as a String.

Overrides:
toString in class java.lang.Object
See Also:
Object.toString()

validate

public java.lang.String validate(CmsFormHandler formHandler)
Description copied from interface: I_CmsField
Validates this field by validating it's constraints and input value.

Specified by:
validate in interface I_CmsField
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
See Also:
I_CmsField.validate(CmsFormHandler)

incrementPlaceholder

protected void incrementPlaceholder(java.lang.String message)
This function sets the cells of placeholder. Its only work with a col size of 2.

Parameters:
message - integer value of adding to the placeholder value

setErrorMessage

protected void setErrorMessage(java.lang.String errorMessage)
Sets the error message if validation failed.

Parameters:
errorMessage - the error message if validation failed

setItems

protected void setItems(java.util.List items)
Sets 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 flag of the item (true or false)

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

setLabel

protected void setLabel(java.lang.String description)
Sets the description text of the input field.

Parameters:
description - the description text of the input field

setMandatory

protected void setMandatory(boolean mandatory)
Sets if this input field is mandatory.

Parameters:
mandatory - true if this input field is mandatory, otherwise false

setName

protected void setName(java.lang.String name)
Sets the name of the input field.

Parameters:
name - the name of the input field

setValidationExpression

protected void setValidationExpression(java.lang.String expression)
Sets the regular expression that is used for validation of the field.

Parameters:
expression - the regular expression that is used for validation of the field

setValue

protected void setValue(java.lang.String value)
Sets the initial value of the field.

Parameters:
value - the initial value of the field

showRowEnd

protected boolean showRowEnd(java.lang.String colSizeTwo)
This functions looks if the row should be end. By one colsize, its everytime ending. By two colsize every second cell its ending.

Parameters:
colSizeTwo - if two cols should be shown
Returns:
true the row end must shown

showRowStart

protected boolean showRowStart(java.lang.String colSizeTwo)
This functions looks if the row should be start. By one colsize, its everytime starting. By two colsize every second cell its starting.

Parameters:
colSizeTwo - if two cols should be shown
Returns:
true if the row should shown

validateConstraints

protected java.lang.String validateConstraints()
Validates the constraints if this field is mandatory.

Returns:
CmsFormHandler.ERROR_MANDATORY if a constraint is violated

validateValue

protected java.lang.String validateValue()
Validates the input value of this field.

Returns:
CmsFormHandler.ERROR_VALIDATION if validation of the input value failed