|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjavax.faces.validator.ValidatorBase
javax.faces.validator.LengthValidator
LengthValidator is a Validator that checks
the number of characters in the String representation of the value of the
associated component. The following algorithm is implemented:
null, exit immediately. (If null values
should not be allowed, a RequiredValidator can be configured
to check for this case.)toString() method.maximum property has been configured on this
Validator, check the length of the converted
String against this limit. If the String length is larger than the
specified minimum, add a MAXIMUM_MESSAGE_ID message to the
FacesContext for this request.minimum property has been configured on this
Validator, check the length of the converted
String against this limit. If the String length is less than the
specified minimum, add a MINIMUM_MESSAGE_ID message to the
FacesContext for this request.
| Field Summary | |
static java.lang.String |
MAXIMUM_MESSAGE_ID
The message identifier of the Message to be created if
the maximum length check fails. |
static java.lang.String |
MINIMUM_MESSAGE_ID
The message identifier of the Message to be created if
the minimum length check fails. |
| Constructor Summary | |
LengthValidator()
Construct a Validator with no preconfigured limits. |
|
LengthValidator(int maximum)
Construct a Validator with the specified preconfigured
limit. |
|
LengthValidator(int maximum,
int minimum)
Construct a Validator with the specified preconfigured
limits. |
|
| Method Summary | |
protected double |
doubleValue(java.lang.Object attributeValue)
Return the specified attribute value, converted to a double. |
int |
getMaximum()
Return the maximum length to be enforced by this Validator, or 0 if the maximum has not been
set. |
protected Message |
getMessage(FacesContext context,
java.lang.String messageId)
Return a Message for the specified parameters. |
protected Message |
getMessage(FacesContext context,
java.lang.String messageId,
java.lang.Object[] params)
Return a Message for the specified parameters. |
protected MessageResources |
getMessageResources()
Return the MessageResources instance for the message
resources defined by the JavaServer Faces Specification. |
int |
getMinimum()
Return the minimum length to be enforced by this Validator, or 0 if the minimum has not been
set. |
boolean |
isMaximumSet()
Return a flag indicating whether a maximum length has been set. |
boolean |
isMinimumSet()
Return a flag indicating whether a minimum limit has been set. |
protected long |
longValue(java.lang.Object attributeValue)
Return the specified attribute value, converted to a long. |
void |
setMaximum(int maximum)
Set the maximum length to be enforced by this Validator. |
void |
setMinimum(int minimum)
Set the minimum length to be enforced by this Validator. |
protected java.lang.String |
stringValue(java.lang.Object attributeValue)
Return the specified attribute value, converted to a String. |
void |
validate(FacesContext context,
UIComponent component)
Perform the correctness checks implemented by this Validator against the specified UIComponent. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public static final java.lang.String MAXIMUM_MESSAGE_ID
The message identifier of the Message to be created if
the maximum length check fails. The message format string for this
message may optionally include a {0} placeholder, which
will be replaced by the configured maximum length.
public static final java.lang.String MINIMUM_MESSAGE_ID
The message identifier of the Message to be created if
the minimum length check fails. The message format string for this
message may optionally include a {0} placeholder, which
will be replaced by the configured minimum length.
| Constructor Detail |
public LengthValidator()
Construct a Validator with no preconfigured limits.
public LengthValidator(int maximum)
Construct a Validator with the specified preconfigured
limit.
maximum - Maximum value to allow
public LengthValidator(int maximum,
int minimum)
Construct a Validator with the specified preconfigured
limits.
maximum - Maximum value to allowminimum - Minimum value to allow
java.lang.IllegalArgumentException - if a specified maximum value is
less than a specified minimum value| Method Detail |
public int getMaximum()
Return the maximum length to be enforced by this Validator, or 0 if the maximum has not been
set.
public void setMaximum(int maximum)
Set the maximum length to be enforced by this Validator.
maximum - The new maximum value
java.lang.IllegalArgumentException - if a specified maximum value is
less than a specified minimum valuepublic boolean isMaximumSet()
Return a flag indicating whether a maximum length has been set.
public int getMinimum()
Return the minimum length to be enforced by this Validator, or 0 if the minimum has not been
set.
public void setMinimum(int minimum)
Set the minimum length to be enforced by this Validator.
minimum - The new minimum value
java.lang.IllegalArgumentException - if a specified maximum value is
less than a specified minimum valuepublic boolean isMinimumSet()
Return a flag indicating whether a minimum limit has been set.
public void validate(FacesContext context,
UIComponent component)
ValidatorPerform the correctness checks implemented by this
Validator against the specified UIComponent.
If any violations are found:
Messages to the specified
FacesContext, specifying this UIComponent as
associated with the message, describing the nature of the
violation(s) encountered.valid property on the specified
UIComponent to false.
protected Message getMessage(FacesContext context,
java.lang.String messageId)
Return a Message for the specified parameters.
context - The FacesContext associated with the request
being processedmessageId - Message identifier of the requested message
protected Message getMessage(FacesContext context,
java.lang.String messageId,
java.lang.Object[] params)
Return a Message for the specified parameters.
context - The FacesContext associated with the request
being processedmessageId - Message identifier of the requested messageparams - Substitution parameters for this messageprotected MessageResources getMessageResources()
Return the MessageResources instance for the message
resources defined by the JavaServer Faces Specification.
protected double doubleValue(java.lang.Object attributeValue)
throws java.lang.NumberFormatException
Return the specified attribute value, converted to a
double.
attributeValue - The attribute value to be converted
java.lang.NumberFormatException - if conversion is not possible
protected long longValue(java.lang.Object attributeValue)
throws java.lang.NumberFormatException
Return the specified attribute value, converted to a
long.
attributeValue - The attribute value to be converted
java.lang.NumberFormatException - if conversion is not possibleprotected java.lang.String stringValue(java.lang.Object attributeValue)
Return the specified attribute value, converted to a
String.
attributeValue - The attribute value to be converted
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||