|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.wicket.behavior.Behavior org.apache.wicket.validation.validator.AbstractRangeValidator<Integer,String> org.apache.wicket.validation.validator.StringValidator
public class StringValidator
Validator for checking if length of a string falls within [min,max] range.
If either min or max are null
they are not checked.
If the component is attached to an input
tag, a maxlen
attribute will be added if
the maximum is set.
*
Resource keys:
RangeValidator.exact
if min==max (exactLength(int)
)RangeValidator.range
if both min and max are not null
RangeValidator.minimum
if max is null
(minimumLength(int)
)RangeValidator.maximum
if min is null
(maximumLength(int)
)StringValidator.*
are still
checked)
Error Message Variables:
name
: the id of Component
that failedlabel
: the label of the Component
(either comes from
FormComponent.labelModel
or resource key <form-id>.<form-component-id>
input
: the input valuelength
: the length of the enteredminimum
: the minimum alloed lengthmaximum
: the maximum allowed length
Nested Class Summary |
---|
Nested classes/interfaces inherited from class org.apache.wicket.validation.validator.AbstractRangeValidator |
---|
AbstractRangeValidator.Mode |
Constructor Summary | |
---|---|
protected |
StringValidator()
Constructor used for subclasses who want to set the range using AbstractRangeValidator.setRange(Comparable, Comparable) |
|
StringValidator(Integer minimum,
Integer maximum)
Constructor that sets the minimum and maximum length values. |
Method Summary | |
---|---|
protected ValidationError |
decorate(ValidationError error,
IValidatable<String> validatable)
Allows subclasses to decorate reported errors |
static StringValidator |
exactLength(int length)
|
protected Integer |
getValue(IValidatable<String> validatable)
Gets the value that should be validated against the range |
static StringValidator |
lengthBetween(int minimum,
int maximum)
|
static StringValidator |
maximumLength(int length)
|
static StringValidator |
minimumLength(int length)
|
void |
onComponentTag(Component component,
ComponentTag tag)
Called any time a component that has this behavior registered is rendering the component tag. |
Methods inherited from class org.apache.wicket.validation.validator.AbstractRangeValidator |
---|
getMaximum, getMinimum, getMode, setRange, validate |
Methods inherited from class org.apache.wicket.behavior.Behavior |
---|
afterRender, beforeRender, bind, canCallListenerInterface, detach, getStatelessHint, isEnabled, isTemporary, onConfigure, onEvent, onException, renderHead, unbind |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public StringValidator(Integer minimum, Integer maximum)
minimum
- the minimum lenghhmaximum
- the maximum lengthprotected StringValidator()
AbstractRangeValidator.setRange(Comparable, Comparable)
Method Detail |
---|
protected Integer getValue(IValidatable<String> validatable)
AbstractRangeValidator
getValue
in class AbstractRangeValidator<Integer,String>
protected ValidationError decorate(ValidationError error, IValidatable<String> validatable)
AbstractRangeValidator
decorate
in class AbstractRangeValidator<Integer,String>
public void onComponentTag(Component component, ComponentTag tag)
Behavior
onComponentTag
in class Behavior
component
- the component that renders this tag currentlytag
- the tag that is renderedpublic static StringValidator exactLength(int length)
length
-
StringValidator
that generates an error if a string is not of an exact
lengthpublic static StringValidator maximumLength(int length)
length
-
StringValidator
that generates an error if a string exceeds a maximum
lengthpublic static StringValidator minimumLength(int length)
length
-
StringValidator
that generates an error if a string is not of a minimum
lengthpublic static StringValidator lengthBetween(int minimum, int maximum)
minimum
- maximum
-
StringValidator
that generates an error if the length of a string is not
between (inclusive) minimum and maximum
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |