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:
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 maximum, throw a
ValidatorException containing a a MAXIMUM_MESSAGE_ID message.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, throw a
ValidatorException containing a a MINIMUM_MESSAGE_ID message.
For all of the above cases that cause a ValidatorException to be thrown, if there are parameters to the
message that match up with validator parameters, the values of these parameters must be converted using the
Converter registered in the application under the converter id jakarta.faces.Number. This allows
the values to be localized according to the current Locale.
| Modifier and Type | Field and Description |
|---|---|
| private boolean | |
| private Integer | |
| public static final String | MAXIMUM_MESSAGE_ID
The message identifier of the |
| private Integer | |
| public static final String | MINIMUM_MESSAGE_ID
The message identifier of the |
| private boolean | |
| public static final String | VALIDATOR_ID
The standard validator id for this validator. |
| Access | Constructor and Description |
|---|---|
| public | |
| public | LengthValidator(int
Maximum value to allow maximum)
Construct a |
| public | LengthValidator(int
Maximum value to allow maximum, int Minimum value to allow minimum)
Construct a |
| Modifier and Type | Method and Description |
|---|---|
| public void | clearInitialState()
Implements jakarta. Reset the PartialStateHolder to a non-delta tracking state. |
| public boolean | equals(Object
the reference object with which to compare. otherObj)Overrides java. |
| public int | Returns: the maximum
Return the maximum length to be enforced by this |
| public int | Returns: the minimum
Return the minimum length to be enforced by this |
| public int | |
| public boolean | initialStateMarked()
Implements jakarta.
Return |
| private static String | |
| private boolean | |
| private boolean | |
| public boolean | isTransient()
Implements jakarta. If true, the Object implementing this interface must not participate in state saving or restoring. |
| public void | markInitialState()
Implements jakarta.
The runtime must ensure that the |
| public void | restoreState(FacesContext
the Faces context. context, Object the state. state)Implements jakarta. Perform any processing required to restore the state from the entries in the state Object. |
| public Object | saveState(FacesContext
the Faces context. context)Implements jakarta.
Gets the state of the instance as a |
| public void | setMaximum(int
The new maximum value maximum)
Set the maximum length to be enforced by this |
| public void | setMinimum(int
The new minimum value minimum)
Set the minimum length to be enforced by this |
| public void | setTransient(boolean
boolean pass transientValue)true if this Object will
not participate in state saving or restoring, otherwise pass false.Implements jakarta. Denotes whether or not the Object implementing this interface must or must not participate in state saving or restoring. |
| private static String | stringValue(Object
The attribute value to be converted attributeValue)
Return the specified attribute value, converted to a |
| public void | validate(FacesContext
FacesContext for the request we are processing context, UIComponent UIComponent we are checking for correctness component, Object the value to validate value)Implements jakarta.
Perform the correctness checks implemented by this |
| initialState | back to summary |
|---|---|
| private boolean initialState | |
| maximum | back to summary |
|---|---|
| private Integer maximum | |
| MAXIMUM_MESSAGE_ID | back to summary |
|---|---|
| public static final String MAXIMUM_MESSAGE_ID
The message identifier of the
| |
| minimum | back to summary |
|---|---|
| private Integer minimum | |
| MINIMUM_MESSAGE_ID | back to summary |
|---|---|
| public static final String MINIMUM_MESSAGE_ID
The message identifier of the
| |
| transientValue | back to summary |
|---|---|
| private boolean transientValue | |
| VALIDATOR_ID | back to summary |
|---|---|
| public static final String VALIDATOR_ID The standard validator id for this validator. | |
| LengthValidator | back to summary |
|---|---|
| public LengthValidator()
Construct a | |
| LengthValidator | back to summary |
|---|---|
| public LengthValidator(int maximum)
Construct a
| |
| LengthValidator | back to summary |
|---|---|
| public LengthValidator(int maximum, int minimum)
Construct a
| |
| clearInitialState | back to summary |
|---|---|
| public void clearInitialState() Implements jakarta. Doc from jakarta. Reset the PartialStateHolder to a non-delta tracking state.
| |
| equals | back to summary |
|---|---|
| public boolean equals(Object otherObj) Overrides java. Doc from java. Indicates whether some other object is "equal to" this one.
The
An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes. | |
| getMaximum | back to summary |
|---|---|
| public int getMaximum()
Return the maximum length to be enforced by this
| |
| getMinimum | back to summary |
|---|---|
| public int getMinimum()
Return the minimum length to be enforced by this
| |
| hashCode | back to summary |
|---|---|
| public int hashCode() Overrides java. Doc from java. Returns a hash code value for the object. This method is
supported for the benefit of hash tables such as those provided by
The general contract of
| |
| initialStateMarked | back to summary |
|---|---|
| public boolean initialStateMarked() Implements jakarta. Doc from jakarta.
Return
| |
| integerToString | back to summary |
|---|---|
| private static String integerToString(UIComponent component, Integer toConvert, FacesContext context) | |
| isMaximumSet | back to summary |
|---|---|
| private boolean isMaximumSet() | |
| isMinimumSet | back to summary |
|---|---|
| private boolean isMinimumSet() | |
| isTransient | back to summary |
|---|---|
| public boolean isTransient() Implements jakarta. Doc from jakarta. If true, the Object implementing this interface must not participate in state saving or restoring.
| |
| markInitialState | back to summary |
|---|---|
| public void markInitialState() Implements jakarta. Doc from jakarta.
The runtime must ensure that the
| |
| restoreState | back to summary |
|---|---|
| public void restoreState(FacesContext context, Object state) Implements jakarta. Doc from jakarta. Perform any processing required to restore the state from the entries in the state Object.
If the class that implements this interface has references to instances that also implement StateHolder (such as a
If the
| |
| saveState | back to summary |
|---|---|
| public Object saveState(FacesContext context) Implements jakarta. Doc from jakarta.
Gets the state of the instance as a
If the class that implements this interface has references to instances that implement StateHolder (such as a
This method must not alter the state of the implementing object. In other words, after executing this code:
The return from this method must be
| |
| setMaximum | back to summary |
|---|---|
| public void setMaximum(int maximum)
Set the maximum length to be enforced by this
| |
| setMinimum | back to summary |
|---|---|
| public void setMinimum(int minimum)
Set the minimum length to be enforced by this
| |
| setTransient | back to summary |
|---|---|
| public void setTransient(boolean transientValue) Implements jakarta. Doc from jakarta. Denotes whether or not the Object implementing this interface must or must not participate in state saving or restoring.
| |
| stringValue | back to summary |
|---|---|
| private static String stringValue(Object attributeValue)
Return the specified attribute value, converted to a
| |
| validate | back to summary |
|---|---|
| public void validate(FacesContext context, UIComponent component, Object value) throws ValidatorException Implements jakarta. Doc from jakarta.
Perform the correctness checks implemented by this
For a validator to be fully compliant with Version 2 and later of the specification, it must not fail validation on
| |