adapforms.form.elements
Class ToggleElement

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

public class ToggleElement
extends ValueHoldingElement

Toggle element capable of holding a boolean value.

The value type is Boolean.

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

Constructor Summary
ToggleElement(java.lang.String id, SimpleLabel label)
           
 
Method Summary
 ToggleElement clone(java.lang.String id, SimpleLabel label)
          Create a clone of the element, given a new ID and label.
 java.lang.Boolean convertValue(java.lang.Object rawValue, Localization localization)
          Given a raw input value, perform relevant conversions, so that the type integrity is preserved.
 boolean getDefault()
          Default value to be inserted into the form at instantiation.
 java.lang.Boolean getInitialValue()
          Get the value this element should be initialized with when the element is instantiated in the form instance.
 java.lang.String marshallValue(java.lang.Object value)
          Given a value of the expected type, convert it to a string representation.
 void setDefault(boolean value)
          See getDefault().
 java.lang.String toString()
          Used for pretty-printing the element.
 
Methods inherited from class adapforms.form.elements.ValueHoldingElement
buildError, buildSingleError, cloneFinalize, getRolesWrite, getValidationRules, isEmptyValue, isReadOnly, isRequired, setReadOnly, setRequired, setRolesWrite, setValidationRules, toStringHelper, validateValue
 
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

ToggleElement

public ToggleElement(java.lang.String id,
                     SimpleLabel label)
Method Detail

clone

public ToggleElement 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 boolean getDefault()
Default value to be inserted into the form at instantiation.


setDefault

public void setDefault(boolean value)
See getDefault().


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

convertValue

public java.lang.Boolean 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

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.Boolean 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