@JSFValidator(name="f:validateRegex",
bodyContent="empty",
tagClass="org.apache.myfaces.taglib.core.ValidateRegexTag")
@JSFJspProperty(name="binding",
returnType="javax.faces.validator.RegexValidator",
longDesc="A ValueExpression that evaluates to a RegexValidator.")
public class RegexValidator
extends Object
implements Validator, PartialStateHolder
RegexValidator is a Validator
that checks the value of the corresponding component against specified
pattern using Java regular expression syntax.
The regular expression syntax accepted by the RegexValidator class is
same as mentioned in class Pattern in package
java.util.regex.
The following algorithm is implemented:
null, exit immediately.NOT_MATCHED_MESSAGE_ID
error message.
null or an
empty String, throw a ValidatorException
with a PATTERN_NOT_SET_MESSAGE_ID message.
Pattern, throw a ValidatorException
with a (@link #MATCH_EXCEPTION_MESSAGE_ID} message.
pattern property has been configured on this
Validator, check the passed value against this pattern.
If value does not match pattern throw a ValidatorException
containing a NOT_MATCHED_MESSAGE_ID message.
| Modifier and Type | Field and Description |
|---|---|
static String |
MATCH_EXCEPTION_MESSAGE_ID
This message ID is used when the pattern is not a valid regular expression, according
to the rules as defined in class
Pattern |
static String |
NOT_MATCHED_MESSAGE_ID
This message ID is used when the passed value is not a String, or when
the pattern does not match the passed value.
|
static String |
PATTERN_NOT_SET_MESSAGE_ID
This message ID is used when the pattern is
null, or an empty String. |
static String |
VALIDATOR_ID
Converter ID, as defined by the JSF 2.0 specification.
|
NOT_IN_RANGE_MESSAGE_ID| Constructor and Description |
|---|
RegexValidator() |
| Modifier and Type | Method and Description |
|---|---|
void |
clearInitialState() |
String |
getPattern()
Return the ValueExpression that yields the regular expression pattern when evaluated.
|
boolean |
initialStateMarked() |
boolean |
isTransient() |
void |
markInitialState() |
void |
restoreState(FacesContext context,
Object state) |
Object |
saveState(FacesContext context) |
void |
setPattern(String pattern)
The Regular Expression property to validate against.
|
void |
setTransient(boolean isTransient) |
void |
validate(FacesContext context,
UIComponent component,
Object value) |
public static final String VALIDATOR_ID
public static final String PATTERN_NOT_SET_MESSAGE_ID
null, or an empty String.public static final String NOT_MATCHED_MESSAGE_ID
public static final String MATCH_EXCEPTION_MESSAGE_ID
Patternpublic void validate(FacesContext context, UIComponent component, Object value)
public Object saveState(FacesContext context)
saveState in interface StateHolderpublic void restoreState(FacesContext context, Object state)
restoreState in interface StateHolderpublic boolean isTransient()
isTransient in interface StateHolderpublic void setTransient(boolean isTransient)
setTransient in interface StateHolderpublic void setPattern(String pattern)
pattern - a ValueExpression that evaluates to a String that is the regular expression pattern@JSFProperty(required=true) public String getPattern()
public void clearInitialState()
clearInitialState in interface PartialStateHolderpublic boolean initialStateMarked()
initialStateMarked in interface PartialStateHolderpublic void markInitialState()
markInitialState in interface PartialStateHolderCopyright © 2016 The Apache Software Foundation. All Rights Reserved.