01: /**
02: /*
03: * Copyright 2004 The Apache Software Foundation.
04: *
05: * Licensed under the Apache License, Version 2.0 (the "License");
06: * you may not use this file except in compliance with the License.
07: * You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */package org.apache.myfaces.taglib.core;
17:
18: import org.apache.myfaces.convert.ConverterUtils;
19:
20: import javax.faces.validator.DoubleRangeValidator;
21: import javax.faces.validator.Validator;
22: import javax.servlet.jsp.JspException;
23:
24: /**
25: * @author Thomas Spiegl (latest modification by $Author: baranda $)
26: * @author Manfred Geiler
27: * @version $Revision: 467963 $ $Date: 2006-10-26 13:33:25 +0200 (Do, 26 Okt 2006) $
28: */
29: public class ValidateDoubleRangeTag extends
30: GenericMinMaxValidatorTag<Double> {
31: private static final long serialVersionUID = 6396116656224588016L;
32:
33: private static final String VALIDATOR_ID = "javax.faces.DoubleRange";
34:
35: protected Validator createValidator() throws JspException {
36: setValidatorIdString(VALIDATOR_ID);
37: DoubleRangeValidator validator = (DoubleRangeValidator) super
38: .createValidator();
39: if (null != _min) {
40: validator.setMinimum(_min);
41: }
42: if (null != _max) {
43: validator.setMaximum(_max);
44: }
45: return validator;
46: }
47:
48: @Override
49: protected boolean isMinLTMax() {
50: return _min < _max;
51: }
52:
53: @Override
54: protected Double getValue(Object value) {
55: return ConverterUtils.convertToDouble(value);
56: }
57: }
|