Class RangeValidator<Z extends Comparable<? super Z> & Serializable>
- java.lang.Object
-
- org.apache.wicket.behavior.Behavior
-
- org.apache.wicket.validation.validator.AbstractRangeValidator<Z,Z>
-
- org.apache.wicket.validation.validator.RangeValidator<Z>
-
- Type Parameters:
Z
- type of validatable
- All Implemented Interfaces:
Serializable
,IComponentAwareEventSink
,IComponentAwareHeaderContributor
,IClusterable
,IValidator<Z>
- Direct Known Subclasses:
DateValidator
public class RangeValidator<Z extends Comparable<? super Z> & Serializable> extends AbstractRangeValidator<Z,Z>
Validator for checking if a given value falls within [min,max] range. If either min or max arenull
they are not checked.Resource keys:
RangeValidator.exact
if min==maxRangeValidator.range
if both min and max are notnull
RangeValidator.minimum
if max isnull
RangeValidator.maximum
if min isnull
Error Message Variables:
name
: the id ofComponent
that failedlabel
: the label of theComponent
(either comes fromFormComponent.labelModel
or resource key<form-id>.<form-component-id>
input
: the input valueminimum
: the minimum allowed valuemaximum
: the maximum allowed value
- Author:
- igor
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.apache.wicket.validation.validator.AbstractRangeValidator
AbstractRangeValidator.Mode
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
RangeValidator()
Constructor used for subclasses who want to set the range usingAbstractRangeValidator.setRange(Comparable, Comparable)
RangeValidator(Z minimum, Z maximum)
Constructor that sets the minimum and maximum values.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected Z
getValue(IValidatable<Z> validatable)
Gets the value that should be validated against the rangestatic <T extends Comparable<? super T> & Serializable>
RangeValidator<T>maximum(T maximum)
static <T extends Comparable<? super T> & Serializable>
RangeValidator<T>minimum(T minimum)
static <T extends Comparable<? super T> & Serializable>
RangeValidator<T>range(T minimum, T maximum)
-
Methods inherited from class org.apache.wicket.validation.validator.AbstractRangeValidator
decorate, getMaximum, getMinimum, getMode, setRange, validate
-
Methods inherited from class org.apache.wicket.behavior.Behavior
afterRender, beforeRender, bind, canCallListener, detach, getStatelessHint, isEnabled, isTemporary, onAttribute, onComponentTag, onConfigure, onEvent, onException, onRemove, onTag, renderHead, unbind
-
-
-
-
Constructor Detail
-
RangeValidator
public RangeValidator(Z minimum, Z maximum)
Constructor that sets the minimum and maximum values.- Parameters:
minimum
- the minimum valuemaximum
- the maximum value
-
RangeValidator
protected RangeValidator()
Constructor used for subclasses who want to set the range usingAbstractRangeValidator.setRange(Comparable, Comparable)
-
-
Method Detail
-
range
public static <T extends Comparable<? super T> & Serializable> RangeValidator<T> range(T minimum, T maximum)
- Parameters:
minimum
-maximum
-- Returns:
- a
RangeValidator
that validates if a value falls within a range
-
minimum
public static <T extends Comparable<? super T> & Serializable> RangeValidator<T> minimum(T minimum)
- Parameters:
minimum
-- Returns:
- a
RangeValidator
that validates if a value is a leastminimum
-
maximum
public static <T extends Comparable<? super T> & Serializable> RangeValidator<T> maximum(T maximum)
- Parameters:
maximum
-- Returns:
- a
RangeValidator
that validates if a value is a mostmaximum
-
getValue
protected Z getValue(IValidatable<Z> validatable)
Description copied from class:AbstractRangeValidator
Gets the value that should be validated against the range- Specified by:
getValue
in classAbstractRangeValidator<Z extends Comparable<? super Z> & Serializable,Z extends Comparable<? super Z> & Serializable>
- Returns:
- value to validate
-
-