01: /*
02: * Copyright 2004 The Apache Software Foundation.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16: package org.apache.myfaces.taglib.core;
17:
18: import org.apache.myfaces.convert.ConverterUtils;
19:
20: import javax.faces.validator.LongRangeValidator;
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: 467964 $ $Date: 2006-10-26 13:39:52 +0200 (Do, 26 Okt 2006) $
28: */
29: public class ValidateLongRangeTag extends
30: GenericMinMaxValidatorTag<Long> {
31: private static final long serialVersionUID = -8259560474198200978L;
32:
33: private static final String VALIDATOR_ID = "javax.faces.LongRange";
34:
35: protected Validator createValidator() throws JspException {
36: setValidatorIdString(VALIDATOR_ID);
37: LongRangeValidator validator = (LongRangeValidator) 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: protected boolean isMinLTMax() {
49: return _min < _max;
50: }
51:
52: protected Long getValue(Object value) {
53: return ConverterUtils.convertToLong(value);
54: }
55: }
|