net.sf.click.extras.control
Class LongField

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.NumberField
                  extended bynet.sf.click.extras.control.LongField
All Implemented Interfaces:
Control, Serializable

public class LongField
extends NumberField

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

Long Field
LongField will validate the number when the control is processed and invoke the control listener if defined.

The LongField uses a JavaScript onkeypress() integerFilter() method to prevent users from entering invalid characters. To enable number key filtering reference $jsImports and $cssImports in your page template. For example:

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

See also W3C HTML reference INPUT

Author:
Malcolm Edgar
See Also:
Serialized Form

Field Summary
 
Fields inherited from class net.sf.click.extras.control.NumberField
HTML_IMPORTS, maxvalue, minvalue, numberFormat, pattern, VALIDATE_NUMBER_FIELD_FUNCTION
 
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
LongField()
          Create a LongField with no name defined.
LongField(String name)
          Construct a LongField field with the given name.
LongField(String name, boolean required)
          Construct a LongField field with the given name and required status.
LongField(String name, String label)
          Construct a LongField field with the given name and label.
LongField(String name, String label, boolean required)
          Construct a LongField field with the given name, label and required status.
LongField(String name, String label, int size)
          Construct the LongField with the given name, label and size.
LongField(String name, String label, int size, boolean required)
          Construct the LongField with the given name, label, size and required status.
 
Method Summary
 Integer getInteger()
          Return the field Integer value, or null if value was empty or a parsing error occured.
 Long getLong()
          Return the field Long value, or null if value was empty or a parsing error occured.
 Object getValueObject()
          Return the field Long value, or null if value was empty or a parsing error occured.
 void setValueObject(Object object)
          Set the long value of the field using the given object.
 void validate()
          Validate the LongField request submission.
 
Methods inherited from class net.sf.click.extras.control.NumberField
getHtmlImports, getMaxValue, getMinValue, getNumber, getNumberFormat, getPattern, getRequestValue, getValidationJavaScript, onDeploy, setMaxValue, setMinValue, setNumber, setNumberFormat, setPattern
 
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, getTabIndex, getTextAlign, getTitle, getValidate, getValue, 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, 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
 

Constructor Detail

LongField

public LongField(String name)
Construct a LongField field with the given name.

Parameters:
name - the name of the field

LongField

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

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

LongField

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

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

LongField

public LongField(String name,
                 String label,
                 boolean required)
Construct a LongField field 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

LongField

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

LongField

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

LongField

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

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

Method Detail

getLong

public Long getLong()
Return the field Long value, or null if value was empty or a parsing error occured.

Returns:
the field Long value

getInteger

public Integer getInteger()
Return the field Integer value, or null if value was empty or a parsing error occured.

Returns:
the field Integer value

getValueObject

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

Overrides:
getValueObject in class NumberField
Returns:
the Long object representation of the Field value
See Also:
Field.getValueObject()

setValueObject

public void setValueObject(Object object)
Set the long value of the field using the given object.

Overrides:
setValueObject in class NumberField
Parameters:
object - the object value to set
See Also:
Field.setValueObject(Object)

validate

public void validate()
Validate the LongField 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-required-error
    • number-format-error
    • number-maxvalue-error
    • number-minvalue-error

Overrides:
validate in class NumberField