You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by mg...@apache.org on 2013/02/19 16:43:35 UTC
git commit: WICKET-5046 NumberTextField should use appropriate
validator
Updated Branches:
refs/heads/master e88853150 -> 59219bfcc
WICKET-5046 NumberTextField should use appropriate validator
Project: http://git-wip-us.apache.org/repos/asf/wicket/repo
Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/59219bfc
Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/59219bfc
Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/59219bfc
Branch: refs/heads/master
Commit: 59219bfcce8386609cf792ff49b069e95cb79183
Parents: e888531
Author: Martin Tzvetanov Grigorov <mg...@apache.org>
Authored: Tue Feb 19 17:42:24 2013 +0200
Committer: Martin Tzvetanov Grigorov <mg...@apache.org>
Committed: Tue Feb 19 17:43:25 2013 +0200
----------------------------------------------------------------------
.../wicket/markup/html/form/NumberTextField.java | 35 ++-------------
1 files changed, 4 insertions(+), 31 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/wicket/blob/59219bfc/wicket-core/src/main/java/org/apache/wicket/markup/html/form/NumberTextField.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/markup/html/form/NumberTextField.java b/wicket-core/src/main/java/org/apache/wicket/markup/html/form/NumberTextField.java
index 0e88c7b..f58c4cb 100644
--- a/wicket-core/src/main/java/org/apache/wicket/markup/html/form/NumberTextField.java
+++ b/wicket-core/src/main/java/org/apache/wicket/markup/html/form/NumberTextField.java
@@ -22,7 +22,6 @@ import org.apache.wicket.markup.ComponentTag;
import org.apache.wicket.model.IModel;
import org.apache.wicket.util.convert.ConversionException;
import org.apache.wicket.util.convert.IConverter;
-import org.apache.wicket.util.lang.Numbers;
import org.apache.wicket.util.lang.Objects;
import org.apache.wicket.util.value.IValueMap;
import org.apache.wicket.validation.validator.RangeValidator;
@@ -126,40 +125,14 @@ public class NumberTextField<N extends Number & Comparable<N>> extends TextField
if (validator != null)
{
remove(validator);
+ validator = null;
}
- validator = new RangeValidator<N>(getMinValue(), getMaxValue());
- add(validator);
- }
-
- private N getMinValue()
- {
- N result;
- if (minimum != null)
- {
- result = minimum;
- }
- else
- {
- Class<N> numberType = getNumberType();
- result = (N)Numbers.getMinValue(numberType);
- }
- return result;
- }
-
- private N getMaxValue()
- {
- N result;
- if (maximum != null)
- {
- result = maximum;
- }
- else
+ if (minimum != null || maximum != null)
{
- Class<N> numberType = getNumberType();
- result = (N)Numbers.getMaxValue(numberType);
+ validator = RangeValidator.range(minimum, maximum);
+ add(validator);
}
- return result;
}
private Class<N> getNumberType()