org.apache.click.extras.control
Class TelephoneField

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.TelephoneField
All Implemented Interfaces:
Serializable, Control, Stateful

public class TelephoneField
extends TextField

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

Telephone Field
TelephoneField will validate the telephone number when the control is processed and invoke the control listener if defined.

The TelephoneField uses a JavaScript onkeypress() noLetterFilter() method to prevent users from entering invalid characters. To enable number key filtering reference the variables $jsElements and $headElements in your page template. For example:

 <html>
 <head>
 $headElements
 </head>
 <body>

 $form

 $jsElements
 </body>
 </html> 

See also W3C HTML reference INPUT

See Also:
Serialized Form

Field Summary
 
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
TelephoneField()
          Create a TelephoneField with no name defined.
TelephoneField(String name)
          Construct the TelephoneField with the given name.
TelephoneField(String name, boolean required)
          Construct the TelephoneField with the given name and required status.
TelephoneField(String name, String label)
          Construct the TelephoneField with the given name and label.
TelephoneField(String name, String label, boolean required)
          Construct the TelephoneField with the given name, label and required status.
TelephoneField(String name, String label, int size)
          Construct the TelephoneField with the given name, label and size.
TelephoneField(String name, String label, int size, boolean required)
          Construct the TelephoneField with the given name, label, size and required status.
 
Method Summary
 void validate()
          Validate the TelephoneField request submission.
 
Methods inherited from class org.apache.click.control.TextField
getControlSizeEst, getMaxLength, getMinLength, getSize, getTag, getType, getValidationJavaScript, 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, getValueObject, 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, setValueObject, setWidth
 
Methods inherited from class org.apache.click.control.AbstractControl
addBehavior, addStyleClass, appendAttributes, dispatchActionEvent, getActionListener, getAttribute, getAttributes, getBehaviors, getContext, getHeadElements, 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

TelephoneField

public TelephoneField(String name)
Construct the TelephoneField with the given name. The default text field size is 20 characters and the minimum valid length is 10 characters.

Parameters:
name - the name of the field

TelephoneField

public TelephoneField(String name,
                      boolean required)
Construct the TelephoneField with the given name and required status. The default text field size is 20 characters and the minimum valid length is 10 characters.

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

TelephoneField

public TelephoneField(String name,
                      String label)
Construct the TelephoneField with the given name and label. The default text field size is 20 characters and the minimum valid length is 10 characters.

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

TelephoneField

public TelephoneField(String name,
                      String label,
                      boolean required)
Construct the TelephoneField with the given name, label and required status. The default text field size is 20 characters and the minimum valid length is 10 characters.

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

TelephoneField

public TelephoneField(String name,
                      String label,
                      int size)
Construct the TelephoneField with the given name, label and size. The default the minimum valid length is 10 characters.

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

TelephoneField

public TelephoneField(String name,
                      String label,
                      int size,
                      boolean required)
Construct the TelephoneField 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

TelephoneField

public TelephoneField()
Create a TelephoneField with no name defined. The default the minimum valid length is 10 characters.

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

Method Detail

validate

public void validate()
Validate the TelephoneField request submission.

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

  • /click-control.properties
    • field-maxlength-error
    • field-minlength-error
    • field-required-error
  • /org/apache/click/extras/control/TelephoneField.properties
    • telephone-format-error

Overrides:
validate in class TextField