org.apache.click.extras.control
Class DoubleField

java.lang.Object
  extended by org.apache.click.control.AbstractControl
      extended by org.apache.click.control.Field
          extended by org.apache.click.control.TextField
              extended by org.apache.click.extras.control.NumberField
                  extended by org.apache.click.extras.control.DoubleField
All Implemented Interfaces:
Serializable, Control, Stateful

public class DoubleField
extends NumberField

Provides a Double Field control:   <input type='text'>.

Double Field
DoubleField will validate the number when the control is processed and invoke the control listener if defined.

The DoubleField uses a JavaScript onkeypress() doubleFilter() method to prevent users from entering invalid characters. To enable number key filtering reference the PageImports object in your page header section. For example:

 <html>
  <head>
   $imports
  </head>
  <body>
   $form
  </body>
 </html> 
The DoubleField has left justified horizontal text alignment, Field.setTextAlign(String).

See also W3C HTML reference INPUT

See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.apache.click.extras.control.NumberField
maxvalue, minvalue, numberFormat, pattern, VALIDATE_NUMBER_FIELD_FUNCTION
 
Fields inherited from class org.apache.click.control.TextField
maxLength, minLength, size, VALIDATE_TEXTFIELD_FUNCTION
 
Fields inherited from class org.apache.click.control.Field
disabled, error, focus, form, help, label, labelStyle, labelStyleClass, parentStyleClassHint, parentStyleHint, readonly, required, tabindex, title, trim, validate, value
 
Fields inherited from class org.apache.click.control.AbstractControl
actionListener, attributes, behaviors, headElements, listener, listenerMethod, messages, name, parent, styles
 
Fields inherited from interface org.apache.click.Control
CONTROL_MESSAGES
 
Constructor Summary
DoubleField()
          Create a DoubleField with no name defined.
DoubleField(String name)
          Construct a DoubleField with the given name.
DoubleField(String name, boolean required)
          Construct a DoubleField with the given name and required status.
DoubleField(String name, String label)
          Construct a DoubleField with the given name and label.
DoubleField(String name, String label, boolean required)
          Construct a DoubleField with the given name, label and required status.
DoubleField(String name, String label, int size)
          Construct the DoubleField with the given name, label and size.
DoubleField(String name, String label, int size, boolean required)
          Construct the DoubleField with the given name, label, size and required status.
 
Method Summary
 Double getDouble()
          Return the field Double value, or null if value was empty or a parsing error occurred.
 Float getFloat()
          Return the field Float value, or null if value was empty or a parsing error occurred.
 Object getValueObject()
          Return the field Double value, or null if value was empty or a parsing error occurred.
 void setDouble(Double doubleValue)
          Set the Double value of the field.
 void validate()
          Validates the NumberField request submission.
 
Methods inherited from class org.apache.click.extras.control.NumberField
getHeadElements, getMaxValue, getMinValue, getNumber, getNumberFormat, getPattern, getValidationJavaScript, setMaxValue, setMinValue, setNumber, setNumberFormat, setPattern, setValueObject
 
Methods inherited from class org.apache.click.control.TextField
getControlSizeEst, getMaxLength, getMinLength, getSize, getTag, getType, render, setMaxLength, setMinLength, setSize
 
Methods inherited from class org.apache.click.control.Field
bindRequestValue, getError, getErrorLabel, getFocus, getFocusJavaScript, getForm, getHelp, getId, getLabel, getLabelStyle, getLabelStyleClass, getParentStyleClassHint, getParentStyleHint, getRequestValue, getState, getTabIndex, getTextAlign, getTitle, getValidate, getValue, getWidth, isDisabled, isHidden, isReadonly, isRequired, isTrim, isValid, onProcess, removeState, renderTagBegin, restoreState, saveState, setDisabled, setError, setErrorMessage, setErrorMessage, setFocus, setForm, setHelp, setLabel, setLabelStyle, setLabelStyleClass, setListener, setParent, setParentStyleClassHint, setParentStyleHint, setReadonly, setRequired, setState, setTabIndex, setTextAlign, setTitle, setTrim, setValidate, setValue, setWidth
 
Methods inherited from class org.apache.click.control.AbstractControl
addBehavior, addStyleClass, appendAttributes, dispatchActionEvent, getActionListener, getAttribute, getAttributes, getBehaviors, getContext, getHtmlImports, getMessage, getMessage, getMessages, getName, getPage, getParent, getStyle, getStyles, hasAttribute, hasAttributes, hasBehaviors, hasStyles, isAjaxTarget, onDeploy, onDestroy, onInit, onRender, removeBehavior, removeStyleClass, renderTagEnd, setActionListener, setAttribute, setId, setName, setStyle, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DoubleField

public DoubleField(String name)
Construct a DoubleField with the given name.

Parameters:
name - the name of the field

DoubleField

public DoubleField(String name,
                   String label)
Construct a DoubleField with the given name and label.

Parameters:
name - the name of the field
label - the label of the field

DoubleField

public DoubleField(String name,
                   boolean required)
Construct a DoubleField with the given name and required status.

Parameters:
name - the name of the field
required - the field required status

DoubleField

public DoubleField(String name,
                   String label,
                   boolean required)
Construct a DoubleField with the given name, label and required status.

Parameters:
name - the name of the field
label - the label of the field
required - the field required status

DoubleField

public DoubleField(String name,
                   String label,
                   int size)
Construct the DoubleField with the given name, label and size.

Parameters:
name - the name of the field
label - the label of the field
size - the size of the field

DoubleField

public DoubleField(String name,
                   String label,
                   int size,
                   boolean required)
Construct the DoubleField with the given name, label, size and required status.

Parameters:
name - the name of the field
label - the label of the field
size - the size of the field
required - the field required status

DoubleField

public DoubleField()
Create a DoubleField with no name defined.

Please note the control's name must be defined before it is valid.

Method Detail

getDouble

public Double getDouble()
Return the field Double value, or null if value was empty or a parsing error occurred.

Returns:
the field Double value

setDouble

public void setDouble(Double doubleValue)
Set the Double value of the field.

Parameters:
doubleValue - the double value to set

getFloat

public Float getFloat()
Return the field Float value, or null if value was empty or a parsing error occurred.

Returns:
the field Float value

getValueObject

public Object getValueObject()
Return the field Double value, or null if value was empty or a parsing error occurred.

Overrides:
getValueObject in class NumberField
Returns:
the Double object representation of the Field value

validate

public void validate()
Validates the NumberField request submission. If the value entered by the user can be parsed by the NumberFormat the string value of this Field (Field.getValue()) is set to the formatted value of the user input.

A field error message is displayed if a validation error occurs. These messages are defined in the resource bundle:

  • /click-control.properties
    • field-required-error
    • number-format-error
    • number-maxvalue-error
    • number-minvalue-error

Overrides:
validate in class NumberField