KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cocoon > faces > taglib > ValidateLongRangeTag


1 /*
2  * Copyright 1999-2005 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.cocoon.faces.taglib;
17
18 import org.apache.cocoon.faces.FacesUtils;
19 import org.xml.sax.Attributes JavaDoc;
20 import org.xml.sax.SAXException JavaDoc;
21
22 import javax.faces.validator.LongRangeValidator;
23 import javax.faces.validator.Validator;
24
25 /**
26  * @version $Id: ValidateLongRangeTag.java 161271 2005-04-14 13:02:02Z vgritsenko $
27  */

28 public class ValidateLongRangeTag extends ValidatorTag {
29
30     private String JavaDoc minimum;
31     private String JavaDoc maximum;
32
33     public void setMaximum(String JavaDoc maximum) {
34         this.maximum = maximum;
35     }
36
37     public void setMinimum(String JavaDoc minimum) {
38         this.minimum = minimum;
39     }
40
41     public int doStartTag(String JavaDoc namespaceURI, String JavaDoc localName, String JavaDoc qName, Attributes JavaDoc atts)
42     throws SAXException JavaDoc {
43         super.setValidatorId("javax.faces.LongRange");
44         return super.doStartTag(namespaceURI, localName, qName, atts);
45     }
46
47     protected Validator createValidator() {
48         final UIComponentTag tag = FacesUtils.findParentUIComponentTag(this);
49         LongRangeValidator validator = (LongRangeValidator) super.createValidator();
50
51         if (maximum != null) {
52             validator.setMaximum(tag.evaluateLong(maximum));
53         }
54         if (minimum != null) {
55             validator.setMinimum(tag.evaluateLong(minimum));
56         }
57
58         return validator;
59     }
60
61     public void recycle() {
62         super.recycle();
63         this.minimum = null;
64         this.maximum = null;
65     }
66 }
67
Popular Tags