Module org.apache.wicket.core
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 are
null
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:
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.wicket.validation.validator.AbstractRangeValidator
AbstractRangeValidator.Mode
-
Constructor Summary
ModifierConstructorDescriptionprotected
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
Modifier and TypeMethodDescriptionprotected 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 Details
-
RangeValidator
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 Details
-
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
- Parameters:
minimum
-- Returns:
- a
RangeValidator
that validates if a value is a leastminimum
-
maximum
- Parameters:
maximum
-- Returns:
- a
RangeValidator
that validates if a value is a mostmaximum
-
getValue
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
-