adapforms.form.elements
Class TextElement

java.lang.Object
  extended by adapforms.form.elements.FormElement
      extended by adapforms.form.elements.ValueHoldingElement
          extended by adapforms.form.elements.TextElement

public class TextElement
extends ValueHoldingElement

Text element: Holds any string value.

Value type is String.

Author:
Henrik Gammelmark, geemark@daimi.au.dk

Constructor Summary
TextElement(java.lang.String id, SimpleLabel label, boolean passwordMask)
           
 
Method Summary
 TextElement clone(java.lang.String id, SimpleLabel label)
          Create a clone of the element, given a new ID and label.
 java.lang.String convertValue(java.lang.Object rawValue, Localization localization)
          Given a raw input value, perform relevant conversions, so that the type integrity is preserved.
 java.lang.String getDefault()
          Default value to be inserted in the form at instantiation.
 java.lang.String getInitialValue()
          Get the value this element should be initialized with when the element is instantiated in the form instance.
 int getMaxLength()
          Maximum length of a valid value.
 int getMinLength()
          Minimum length of a valid value.
 java.lang.String getPattern()
          Regular expressions pattern (see Pattern) to use for value validation.
 java.lang.String marshallValue(java.lang.Object value)
          Given a value of the expected type, convert it to a string representation.
 void setDefault(java.lang.String value)
          See getDefault()
 void setMaxLength(int length)
          See getMaxLength().
 void setMinLength(int length)
          See getMinLength().
 void setPattern(java.lang.String regex)
          Set the validation regex pattern.
 java.lang.String toString()
          Used for pretty-printing the element.
 boolean usePasswordMask()
          Determine if the value of the element should be masked as a password.
 java.util.List<ValidationProblem> validateValue(java.lang.Object val, Localization localization)
          Given a converted (see ValueHoldingElement.convertValue(java.lang.Object, adapforms.runtime.i18n.Localization)) value, check if it is valid.
 
Methods inherited from class adapforms.form.elements.ValueHoldingElement
buildError, buildSingleError, cloneFinalize, getRolesWrite, getValidationRules, isEmptyValue, isReadOnly, isRequired, setReadOnly, setRequired, setRolesWrite, setValidationRules, toStringHelper
 
Methods inherited from class adapforms.form.elements.FormElement
cloneFinalize, getElementID, getLabel, getRolesRead, getUIFlags, isRelevant, setRelevant, setRolesRead, setUIFlags
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TextElement

public TextElement(java.lang.String id,
                   SimpleLabel label,
                   boolean passwordMask)
Method Detail

clone

public TextElement clone(java.lang.String id,
                         SimpleLabel label)
Description copied from class: FormElement
Create a clone of the element, given a new ID and label.

Important: The method should call FormElement.cloneFinalize(FormElement) before returning. This adds common parameters to the clone.

Specified by:
clone in class FormElement

getDefault

public java.lang.String getDefault()
Default value to be inserted in the form at instantiation.


setDefault

public void setDefault(java.lang.String value)
See getDefault()


usePasswordMask

public boolean usePasswordMask()
Determine if the value of the element should be masked as a password.


getPattern

public java.lang.String getPattern()
Regular expressions pattern (see Pattern) to use for value validation.


validateValue

public java.util.List<ValidationProblem> validateValue(java.lang.Object val,
                                                       Localization localization)
Description copied from class: ValueHoldingElement
Given a converted (see ValueHoldingElement.convertValue(java.lang.Object, adapforms.runtime.i18n.Localization)) value, check if it is valid. This enables the element to perform simple validation.

Overrides:
validateValue in class ValueHoldingElement
Parameters:
val - Value to validate
localization - Localization to use, when generating problem messages
Returns:
null or empty list if ok, problem list otherwise.

convertValue

public java.lang.String convertValue(java.lang.Object rawValue,
                                     Localization localization)
Description copied from class: ValueHoldingElement
Given a raw input value, perform relevant conversions, so that the type integrity is preserved.

Specified by:
convertValue in class ValueHoldingElement
Parameters:
rawValue - Value to convert
localization - Localization to use, when generating problem messages

setPattern

public void setPattern(java.lang.String regex)
Set the validation regex pattern. See getPattern().


getMaxLength

public int getMaxLength()
Maximum length of a valid value.


setMaxLength

public void setMaxLength(int length)
See getMaxLength().


getMinLength

public int getMinLength()
Minimum length of a valid value.


setMinLength

public void setMinLength(int length)
See getMinLength().


toString

public java.lang.String toString()
Description copied from class: FormElement
Used for pretty-printing the element. See Form.prettyPrintStructure().

Specified by:
toString in class FormElement

marshallValue

public java.lang.String marshallValue(java.lang.Object value)
                               throws TypeException
Description copied from class: ValueHoldingElement
Given a value of the expected type, convert it to a string representation.

Specified by:
marshallValue in class ValueHoldingElement
Parameters:
value - Value to marshall
Returns:
String representation
Throws:
TypeException - If the given value is not recognized

getInitialValue

public java.lang.String getInitialValue()
Description copied from class: ValueHoldingElement
Get the value this element should be initialized with when the element is instantiated in the form instance.

Specified by:
getInitialValue in class ValueHoldingElement
Returns:
Value to set, or null to set no initial value