net.sf.click.extras.control
Class EmailField

java.lang.Object
  extended bynet.sf.click.control.AbstractControl
      extended bynet.sf.click.control.Field
          extended bynet.sf.click.control.TextField
              extended bynet.sf.click.extras.control.EmailField
All Implemented Interfaces:
Control, Serializable

public class EmailField
extends TextField

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

Email Field
EmailField will validate the email when the control is processed and invoke the control listener if defined.

See also W3C HTML reference INPUT

Author:
Malcolm Edgar
See Also:
Serialized Form

Field Summary
static String HTML_IMPORTS
          The EmailField.js imports statement.
protected static String VALIDATE_EMAILFIELD_FUNCTION
          The field validation JavaScript function template.
 
Fields inherited from class net.sf.click.control.TextField
maxLength, minLength, size, VALIDATE_TEXTFIELD_FUNCTION
 
Fields inherited from class net.sf.click.control.Field
disabled, error, focus, form, help, label, readonly, required, tabindex, title, validate, value
 
Fields inherited from class net.sf.click.control.AbstractControl
actionListener, attributes, listener, listenerMethod, messages, name, parent, styles
 
Fields inherited from interface net.sf.click.Control
CONTROL_MESSAGES
 
Constructor Summary
EmailField()
          Create an Email Field with no name defined.
EmailField(String name)
          Construct an Email Field with the given name.
EmailField(String name, boolean required)
          Construct an Email Field with the given name and required status.
EmailField(String name, String label)
          Construct an Email Field with the given name and label.
EmailField(String name, String label, boolean required)
          Construct an Email Field with the given name, label and required status.
EmailField(String name, String label, int size)
          Construct the Email Field with the given name, label and size.
EmailField(String name, String label, int size, boolean required)
          Construct the Email Field with the given name, label, size and required status.
 
Method Summary
 String getHtmlImports()
          Return the HTML head import statements for the JavaScript (click/extras-control.js) file.
 String getValidationJavaScript()
          Return the field JavaScript client side validation function.
 void onDeploy(ServletContext servletContext)
          Deploy the extras-control.js file to the click web directory when the application is initialized.
 void validate()
          Process the EmailField request submission.
 
Methods inherited from class net.sf.click.control.TextField
getControlSizeEst, getMaxLength, getMinLength, getSize, getTag, getType, render, setMaxLength, setMinLength, setSize
 
Methods inherited from class net.sf.click.control.Field
bindRequestValue, getError, getErrorLabel, getFocus, getFocusJavaScript, getForm, getHelp, getId, getLabel, getRequestValue, getTabIndex, getTextAlign, getTitle, getValidate, getValue, getValueObject, getWidth, isDisabled, isHidden, isReadonly, isRequired, isValid, onInit, onProcess, setDisabled, setError, setErrorMessage, setErrorMessage, setErrorMessage, setErrorMessage, setFocus, setForm, setHelp, setLabel, setListener, setParent, setReadonly, setRequired, setTabIndex, setTextAlign, setTitle, setValidate, setValue, setValueObject, setWidth
 
Methods inherited from class net.sf.click.control.AbstractControl
addStyleClass, appendAttributes, getActionListener, getAttribute, getAttributes, getContext, getMessage, getMessage, getMessage, getMessages, getName, getPage, getParent, getStyle, getStyles, hasAttribute, hasAttributes, hasStyles, onDestroy, onRender, registerActionEvent, removeStyleClass, renderTagBegin, renderTagEnd, setActionListener, setAttribute, setId, setName, setStyle, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

VALIDATE_EMAILFIELD_FUNCTION

protected static final String VALIDATE_EMAILFIELD_FUNCTION
The field validation JavaScript function template. The function template arguments are:

See Also:
Constant Field Values

HTML_IMPORTS

public static final String HTML_IMPORTS
The EmailField.js imports statement.

See Also:
Constant Field Values
Constructor Detail

EmailField

public EmailField(String name)
Construct an Email Field with the given name. The default email field size is 30 characters.

Parameters:
name - the name of the field

EmailField

public EmailField(String name,
                  String label)
Construct an Email Field with the given name and label. The default email field size is 30 characters.

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

EmailField

public EmailField(String name,
                  boolean required)
Construct an Email Field with the given name and required status. The default email field size is 30 characters.

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

EmailField

public EmailField(String name,
                  String label,
                  boolean required)
Construct an Email Field with the given name, label and required status. The default email field size is 30 characters.

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

EmailField

public EmailField(String name,
                  String label,
                  int size)
Construct the Email Field 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

EmailField

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

EmailField

public EmailField()
Create an Email Field with no name defined.

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

Method Detail

getHtmlImports

public String getHtmlImports()
Return the HTML head import statements for the JavaScript (click/extras-control.js) file.

Returns:
the HTML head import statements for the JavaScript file
See Also:
Control.getHtmlImports()

getValidationJavaScript

public String getValidationJavaScript()
Return the field JavaScript client side validation function.

The function name must follow the format validate_[id], where the id is the DOM element id of the fields focusable HTML element, to ensure the function has a unique name.

Returns:
the field JavaScript client side validation function

onDeploy

public void onDeploy(ServletContext servletContext)
Deploy the extras-control.js file to the click web directory when the application is initialized.

Parameters:
servletContext - the servlet context
See Also:
Control.onDeploy(ServletContext)

validate

public void validate()
Process the EmailField 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-maxlenght-error
    • field-minlength-error
    • field-required-error
  • /net/sf/click/extras/control/EmailField.properties
    • email-format-error