KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > icesoft > applications > faces > address > FormElement


1 /*
2  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
3  *
4  * "The contents of this file are subject to the Mozilla Public License
5  * Version 1.1 (the "License"); you may not use this file except in
6  * compliance with the License. You may obtain a copy of the License at
7  * http://www.mozilla.org/MPL/
8  *
9  * Software distributed under the License is distributed on an "AS IS"
10  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
11  * License for the specific language governing rights and limitations under
12  * the License.
13  *
14  * The Original Code is ICEfaces 1.5 open source software code, released
15  * November 5, 2006. The Initial Developer of the Original Code is ICEsoft
16  * Technologies Canada, Corp. Portions created by ICEsoft are Copyright (C)
17  * 2004-2006 ICEsoft Technologies Canada, Corp. All Rights Reserved.
18  *
19  * Contributor(s): _____________________.
20  *
21  * Alternatively, the contents of this file may be used under the terms of
22  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"
23  * License), in which case the provisions of the LGPL License are
24  * applicable instead of those above. If you wish to allow use of your
25  * version of this file only under the terms of the LGPL License and not to
26  * allow others to use your version of this file under the MPL, indicate
27  * your decision by deleting the provisions above and replace them with
28  * the notice and other provisions required by the LGPL License. If you do
29  * not delete the provisions above, a recipient may use your version of
30  * this file under either the MPL or the LGPL License."
31  *
32  */

33 package com.icesoft.applications.faces.address;
34
35 /**
36  * FormElement is the superclass for all form elements, excepting the reset
37  * button. FormElement maintains the value of the field and the status image
38  * (blank, alert, or progress). For a 'plain' form element (first name, last
39  * name), a custom converter is used to fix the capitalization.
40  *
41  * @see WordCapitalizationConverter
42  */

43 public class FormElement {
44
45     //basic state information for the component
46
protected String JavaDoc value, image;
47     protected boolean set;
48
49     //status images
50
public static final String JavaDoc IMAGE_ALERT = "status_alert.gif";
51     public static final String JavaDoc IMAGE_BLANK = "status_blank.gif";
52     public static final String JavaDoc IMAGE_PROGRESS = "status_blank.gif";
53
54
55     /**
56      * FormElement constructor sets the default value to "" instead of null.
57      */

58     public FormElement() {
59         setValue("");
60     }
61
62     /**
63      * Resets the element to an empty string.
64      */

65     public void reset() {
66         setValue("");
67     }
68
69     /**
70      * Gets the element value.
71      *
72      * @return the element value
73      */

74     public String JavaDoc getValue() {
75         return this.value;
76     }
77
78     /**
79      * Sets the element value. If the value is non-null the set flag is marked
80      * true; If the value is null it is set to "", the set flag is marked false,
81      * and the element image is set to blank.
82      *
83      * @param value The value to be stored.
84      */

85     public void setValue(String JavaDoc value) {
86
87         if (value != null) {
88
89             if (value.length() > 0) {
90                 this.value = value.trim();
91                 set = true;
92                 return;
93             }
94         }
95
96         this.value = "";
97         setImage(IMAGE_BLANK);
98         set = false;
99     }
100
101     /**
102      * Determine whether the element is set or not.
103      *
104      * @return the element's set status
105      * @see #setValue(String)
106      */

107     public boolean getIsSet() {
108         return this.set;
109     }
110
111     /**
112      * Get the element's status image. These will display next to the element on
113      * the form page.
114      *
115      * @return the element's image.
116      */

117     public String JavaDoc getImage() {
118         return this.image;
119     }
120
121     /**
122      * Set the element's status image.
123      *
124      * @param image the status image to set
125      */

126     public void setImage(String JavaDoc image) {
127         this.image = image;
128     }
129 }
130
Popular Tags