|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objecteu.webtoolkit.jwt.WObject
eu.webtoolkit.jwt.WValidator
eu.webtoolkit.jwt.WRegExpValidator
public class WRegExpValidator
A validator that checks user input against a regular expression.
This validator checks whether user input is matched by the given (perl-like) regular expression.
The following perl features are not supported (since client-side validation cannot handle them):
Usage example:
{
@code
WLineEdit lineEdit = new WLineEdit(this);
// an email address validator
WRegExpValidator validator = new WRegExpValidator(
"[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,4}");
lineEdit.setValidator(validator);
lineEdit.setText("pieter@emweb.be");
}
Note: This validator does not fully support unicode: it matches on the UTF8-encoded representation of the string.
The strings used in this class can be translated by overriding the default values for the following localization keys:
WValidator.State.Invalid: Invalid input
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class eu.webtoolkit.jwt.WValidator |
|---|
WValidator.Result, WValidator.State |
| Constructor Summary | |
|---|---|
WRegExpValidator()
Sets a new regular expression validator. |
|
WRegExpValidator(java.lang.String pattern)
Sets a new regular expression validator that accepts input that matches the given regular expression. |
|
WRegExpValidator(java.lang.String pattern,
WObject parent)
Sets a new regular expression validator that accepts input that matches the given regular expression. |
|
WRegExpValidator(WObject parent)
Sets a new regular expression validator. |
|
| Method Summary | |
|---|---|
int |
getFlags()
Returns regular expression matching flags. |
WString |
getInvalidNoMatchText()
Returns the message displayed when the input does not match. |
java.lang.String |
getJavaScriptValidate()
Creates a Javascript object that validates the input. |
java.lang.String |
getRegExp()
Returns the regular expression for valid input. |
void |
setFlags(int flags)
Sets regular expression matching flags. |
void |
setInvalidNoMatchText(java.lang.CharSequence text)
Sets the message to display when the input does not match. |
void |
setNoMatchText(java.lang.CharSequence text)
Sets the text to be shown if no match can be found. |
void |
setRegExp(java.lang.String pattern)
Sets the regular expression for valid input. |
WValidator.Result |
validate(java.lang.String input)
Validates the given input. |
| Methods inherited from class eu.webtoolkit.jwt.WValidator |
|---|
fixup, getInputFilter, getInvalidBlankText, isMandatory, setInvalidBlankText, setMandatory |
| Methods inherited from class eu.webtoolkit.jwt.WObject |
|---|
addChild, getId, getObjectName, remove, setObjectName, tr |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public WRegExpValidator(WObject parent)
public WRegExpValidator()
Calls this((WObject)null)
public WRegExpValidator(java.lang.String pattern,
WObject parent)
This constructs a validator that matches the perl regular expression
expr.
public WRegExpValidator(java.lang.String pattern)
Calls this(pattern, (WObject)null)
| Method Detail |
|---|
public void setRegExp(java.lang.String pattern)
Sets the perl regular expression expr.
public java.lang.String getRegExp()
Returns the perl regular expression.
public void setFlags(int flags)
public int getFlags()
public WValidator.Result validate(java.lang.String input)
The input is considered valid only when it is blank for a non-mandatory field, or matches the regular expression.
validate in class WValidatorpublic void setNoMatchText(java.lang.CharSequence text)
Sets the text to be shown if no match can be found.
public void setInvalidNoMatchText(java.lang.CharSequence text)
The default value is "Invalid input".
public WString getInvalidNoMatchText()
setInvalidNoMatchText(CharSequence text)public java.lang.String getJavaScriptValidate()
WValidator
The JavaScript expression should evaluate to an object which contains a
validate(text) function, which returns an object that
contains the following two fields:
message that indicates the problem if not valid.Returns an empty string if the validator does not provide a client-side validation implementationq.
Note: The signature and contract changed changed in JWt 3.1.9.
getJavaScriptValidate in class WValidatorWValidator.getInputFilter()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||