public class PatternValidator extends BaseValidator
The validator bean that provides a pattern validation service.
The actual pattern matching algorithm is provided by the
PatternDelegate
. This enables the user to provide
custom pattern matching implementations. In the event a custom implementation is not
provided, this validator will use the RegexpMatcher
.
This validator has the ability to provide client side validation on demand.
To enable client side validation simply set the clientScriptingEnabled
property to true
.
The default implementation of the script will be in JavaScript and allows the user to
override this with a custom implementation by setting the path to the custom
script via setScriptPath(String)
.
FIELD_SYMBOL, FORM_SYMBOL, FUNCTION_SYMBOL, VALIDATOR_SYMBOL
Constructor and Description |
---|
PatternValidator() |
Modifier and Type | Method and Description |
---|---|
java.lang.String |
getEscapedPatternString()
Returns the escaped sequence of the pattern string for rendering in the error message.
|
PatternDelegate |
getPatternDelegate()
Returns the custom pattern matcher if one is provided or creates and returns the
default matcher laziliy.
|
java.lang.String |
getPatternNotMatchedMessage()
Returns custom validation failure message.
|
java.lang.String |
getPatternString()
Returns the pattern that this validator uses for validation.
|
void |
renderValidatorContribution(IFormComponent field,
IMarkupWriter writer,
IRequestCycle cycle)
This implementation does nothing.
|
void |
setPatternDelegate(PatternDelegate patternDelegate)
Allows for a custom implementation to do the pattern matching.
|
void |
setPatternNotMatchedMessage(java.lang.String message)
Allows for a custom message to be set typically via the bean specification.
|
void |
setPatternString(java.lang.String pattern)
Allows the user to change the validation pattern.
|
void |
setScriptPath(java.lang.String scriptPath)
Allows for a custom implementation of the client side validation.
|
java.lang.Object |
toObject(IFormComponent field,
java.lang.String input)
Converts input, submitted by the client, into an object value.
|
java.lang.String |
toString() |
java.lang.String |
toString(IFormComponent field,
java.lang.Object value)
Invoked during rendering to convert an object value (which may be null) to a String.
|
buildRequiredMessage, checkRequired, formatString, formatString, formatString, getPattern, getRequiredMessage, isClientScriptingEnabled, isRequired, processValidatorScript, setClientScriptingEnabled, setRequired, setRequiredMessage
public PatternValidator()
public java.lang.String getPatternNotMatchedMessage()
ValidationStrings.properties
file for key
pattern-not-matched
.public java.lang.String getPatternString()
public void setPatternNotMatchedMessage(java.lang.String message)
public void setPatternString(java.lang.String pattern)
public void setPatternDelegate(PatternDelegate patternDelegate)
RegexpMatcher
.public PatternDelegate getPatternDelegate()
public java.lang.String toString(IFormComponent field, java.lang.Object value)
IValidator
public java.lang.Object toObject(IFormComponent field, java.lang.String input) throws ValidatorException
IValidator
The input string will already have been trimmed. It may be null.
ValidatorException
- if the string cannot be converted into an object, or the object is not valid (due
to other constraints).IValidator.toObject(org.apache.tapestry.form.IFormComponent, java.lang.String)
public void setScriptPath(java.lang.String scriptPath)
public void renderValidatorContribution(IFormComponent field, IMarkupWriter writer, IRequestCycle cycle)
BaseValidator
renderValidatorContribution
in interface IValidator
renderValidatorContribution
in class BaseValidator
IValidator.renderValidatorContribution(org.apache.tapestry.form.IFormComponent, org.apache.tapestry.IMarkupWriter, org.apache.tapestry.IRequestCycle)
public java.lang.String getEscapedPatternString()
public java.lang.String toString()
toString
in class java.lang.Object