Class TextField
- java.lang.Object
-
- org.openidentityplatform.openam.click.control.AbstractControl
-
- org.openidentityplatform.openam.click.control.Field
-
- org.openidentityplatform.openam.click.control.TextField
-
- All Implemented Interfaces:
Serializable,org.apache.click.Stateful,org.openidentityplatform.openam.click.Control
public class TextField extends Field
Provides a Text Field control: <input type='text'>.Example Text Field <input type='text' value='string'/> TextField Example
The example below shows how to a TextField to a Form, and how it will be rendered as HTML.TextField usernameField = new TextField("username"); usernameField.setRequired(true); usernameField.setSize(12); usernameField.setMaxLength(12); usernameField.setMinLength(6); form.add(usernameField);
The TextField control will rendered HTML output:<input type='text' name='username' value='' size='12' maxlength='12'>
For another example using TextField see theFormJavadoc example.See also the W3C HTML reference: INPUT
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected intmaxLengthThe maximum field length validation constraint.protected intminLengthThe minimum field length validation constraint.protected intsizeThe text field size attribute.protected static StringVALIDATE_TEXTFIELD_FUNCTIONThe field validation JavaScript function template.-
Fields inherited from class org.openidentityplatform.openam.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.openidentityplatform.openam.click.control.AbstractControl
actionListener, attributes, behaviors, headElements, listener, listenerMethod, messages, name, parent, styles
-
-
Constructor Summary
Constructors Constructor Description TextField()Create a TextField with no name defined.TextField(String name)Construct the TextField with the given name.TextField(String name, boolean required)Construct the TextField with the given name and required status.TextField(String name, String label)Construct the TextField with the given name and label.TextField(String name, String label, boolean required)Construct the TextField with the given name, label and required status.TextField(String name, String label, int size)Construct the TextField with the given name, label and size.TextField(String name, String label, int size, boolean required)Construct the TextField with the given name, label, size and required status.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intgetControlSizeEst()Return the estimated rendered control size in characters.intgetMaxLength()Returns the maximum field length validation constraint.intgetMinLength()Returns the minimum field length validation constraint.intgetSize()Return the field size.StringgetTag()Return the textfield's html tag:input.StringgetType()Return the input type: 'text'.StringgetValidationJavaScript()Return the field JavaScript client side validation function.voidrender(HtmlStringBuffer buffer)Render the HTML representation of the TextField.voidsetMaxLength(int maxLength)Sets the maximum field length.voidsetMinLength(int minLength)Sets the minimum field length validation constraint.voidsetSize(int size)Set the field size.voidvalidate()Validate the TextField request submission.-
Methods inherited from class org.openidentityplatform.openam.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.openidentityplatform.openam.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
-
-
-
-
Field Detail
-
VALIDATE_TEXTFIELD_FUNCTION
protected static final String VALIDATE_TEXTFIELD_FUNCTION
The field validation JavaScript function template. The function template arguments are:- 0 - is the field id
- 1 - is the Field required status
- 2 - is the minimum length
- 3 - is the maximum length
- 4 - is the localized error message for required validation
- 5 - is the localized error message for minimum length validation
- 6 - is the localized error message for maximum length validation
- See Also:
- Constant Field Values
-
maxLength
protected int maxLength
The maximum field length validation constraint. If the value is zero this validation constraint is not applied. The default value is zero.If maxLength is greater than zero, then maxLength is rendered as the HTML attribute 'maxlength'.
-
minLength
protected int minLength
The minimum field length validation constraint. If the valid is zero this validation constraint is not applied. The default value is zero.
-
size
protected int size
The text field size attribute. The default size is 20.
-
-
Constructor Detail
-
TextField
public TextField(String name)
Construct the TextField with the given name. The default text field size is 20 characters.- Parameters:
name- the name of the field
-
TextField
public TextField(String name, boolean required)
Construct the TextField with the given name and required status. The default text field size is 20 characters.- Parameters:
name- the name of the fieldrequired- the field required status
-
TextField
public TextField(String name, String label)
Construct the TextField with the given name and label. The default text field size is 20 characters.- Parameters:
name- the name of the fieldlabel- the label of the field
-
TextField
public TextField(String name, String label, boolean required)
Construct the TextField with the given name, label and required status. The default text field size is 20 characters.- Parameters:
name- the name of the fieldlabel- the label of the fieldrequired- the field required status
-
TextField
public TextField(String name, String label, int size)
Construct the TextField with the given name, label and size.- Parameters:
name- the name of the fieldlabel- the label of the fieldsize- the size of the field
-
TextField
public TextField(String name, String label, int size, boolean required)
Construct the TextField with the given name, label, size and required status.- Parameters:
name- the name of the fieldlabel- the label of the fieldsize- the size of the fieldrequired- the field required status
-
TextField
public TextField()
Create a TextField with no name defined.Please note the control's name must be defined before it is valid.
-
-
Method Detail
-
getTag
public String getTag()
Return the textfield's html tag:input.- Overrides:
getTagin classAbstractControl- Returns:
- this controls html tag
- See Also:
AbstractControl.getTag()
-
getMaxLength
public int getMaxLength()
Returns the maximum field length validation constraint. If themaxLengthproperty is greater than zero, the Field values length will be validated against this constraint when processed.If maxLength is greater than zero, it is rendered as the field attribute 'maxlength'
- Returns:
- the maximum field length validation constraint
-
setMaxLength
public void setMaxLength(int maxLength)
Sets the maximum field length. If themaxLengthproperty is greater than zero, the Field values length will be validated against this constraint when processed.If maxLength is greater than zero, it is rendered as the field attribute 'maxlength'
- Parameters:
maxLength- the maximum field length validation constraint
-
getMinLength
public int getMinLength()
Returns the minimum field length validation constraint. If theminLengthproperty is greater than zero, the Field values length will be validated against this constraint when processed.- Returns:
- the minimum field length validation constraint
-
setMinLength
public void setMinLength(int minLength)
Sets the minimum field length validation constraint. If theminLengthproperty is greater than zero, the Field values length will be validated against this constraint when processed.- Parameters:
minLength- the minimum field length validation constraint
-
getSize
public int getSize()
Return the field size.- Returns:
- the field size
-
setSize
public void setSize(int size)
Set the field size.- Parameters:
size- the field size
-
getType
public String getType()
Return the input type: 'text'.- Returns:
- the input type: '
text'
-
getControlSizeEst
public int getControlSizeEst()
Description copied from class:AbstractControlReturn the estimated rendered control size in characters.- Overrides:
getControlSizeEstin classAbstractControl- Returns:
- the estimated rendered control size in characters
- See Also:
AbstractControl.getControlSizeEst()
-
render
public void render(HtmlStringBuffer buffer)
Render the HTML representation of the TextField.- Specified by:
renderin interfaceorg.openidentityplatform.openam.click.Control- Overrides:
renderin classAbstractControl- Parameters:
buffer- the specified buffer to render the control's output to- See Also:
AbstractControl.toString()
-
validate
public void validate()
Validate the TextField request submission.A field error message is displayed if a validation error occurs. These messages are defined in the resource bundle:
org.apache.click.control.MessageProperties
Error message bundle key names include:
- field-maxlength-error
- field-minlength-error
- field-required-error
-
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.- Overrides:
getValidationJavaScriptin classField- Returns:
- the field JavaScript client side validation function
-
-