|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sf.click.control.AbstractControl net.sf.click.control.Field net.sf.click.control.TextField net.sf.click.extras.control.RegexField
Provides a Regex Field control: <input type='text'>.
Regex Field |
RegexField versionField = new RegexField("version"); versionField.setPattern("[0-9]+\\.[0-9]+\\.[0-9]+"); form.add(versionField); RegexField urlField = new RegexField("url", "URL"); urlField.setPattern("(http|https)://.+"); form.add(urlField);For details on valid regular expression patterns see Pattern Javadoc. Note for performance reasons the regular expression pattern is compiled when the field is processed not when its value is set. If you set an invalid expression pattern a PatternSyntaxException will be thrown by the
Field.onProcess()
method.
See also the W3C HTML reference: INPUT
Field Summary | |
static String |
HTML_IMPORTS
The RegexField.js imports statement. |
protected String |
pattern
The field pattern based on regular expression. |
protected static String |
VALIDATE_REGEXFIELD_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 | |
RegexField()
Create a RegexField with no name defined. |
|
RegexField(String name)
Construct the RegexField with the given name. |
|
RegexField(String name,
boolean required)
Construct the RegexField with the given name and required status. |
|
RegexField(String name,
String label)
Construct the RegexField with the given name and label. |
|
RegexField(String name,
String label,
boolean required)
Construct the RegexField with the given name, label and required status. |
|
RegexField(String name,
String label,
int size)
Construct the RegexField with the given name, label and size. |
|
RegexField(String name,
String label,
int size,
boolean required)
Construct the RegexField 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 |
getPattern()
Returns the field pattern. |
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 |
setPattern(String pattern)
Sets the field pattern as regular expression. |
void |
validate()
Validate the RegexField 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 |
protected static final String VALIDATE_REGEXFIELD_FUNCTION
public static final String HTML_IMPORTS
protected String pattern
Constructor Detail |
public RegexField(String name)
name
- the name of the fieldpublic RegexField(String name, boolean required)
name
- the name of the fieldrequired
- the field required statuspublic RegexField(String name, String label, boolean required)
name
- the name of the fieldlabel
- the label of the fieldrequired
- the field required statuspublic RegexField(String name, String label, int size)
name
- the name of the fieldlabel
- the label of the fieldsize
- the size of the fieldpublic RegexField(String name, String label, int size, boolean required)
name
- the name of the fieldlabel
- the label of the fieldsize
- the size of the fieldrequired
- the field required statuspublic RegexField(String name, String label)
name
- the name of the fieldlabel
- the label of the fieldpublic RegexField()
Method Detail |
public void setPattern(String pattern)
pattern
- the field regular expression pattern
PatternSyntaxException
- if the regular expression pattern cannot be compiledpublic String getPattern()
public String getHtmlImports()
Control.getHtmlImports()
public String getValidationJavaScript()
public void validate()
- /click-control.properties
- field-maxlength-error
- field-minlength-error
- field-required-error
- /net/sf/click/extras/control/RegexField.properties
- field-pattern-error
PatternSyntaxException
- if the pattern has a
syntax errorpublic void onDeploy(ServletContext servletContext)
servletContext
- the servlet contextControl.onDeploy(ServletContext)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |