View Javadoc

1   /*
2    * $Id: TypeForm.java 421488 2006-07-13 03:43:08Z wsmoak $
3    *
4    * Copyright 2000-2006 The Apache Software Foundation.
5    *
6    * Licensed under the Apache License, Version 2.0 (the "License");
7    * you may not use this file except in compliance with the License.
8    * You may obtain a copy of the License at
9    *
10   *      http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing, software
13   * distributed under the License is distributed on an "AS IS" BASIS,
14   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15   * See the License for the specific language governing permissions and
16   * limitations under the License.
17   */
18  
19  
20  package org.apache.struts.webapp.validator;
21  
22  import java.io.Serializable;
23  import java.util.ArrayList;
24  import java.util.List;
25  import javax.servlet.http.HttpServletRequest;
26  import org.apache.struts.action.ActionMapping;
27  import org.apache.struts.util.LabelValueBean;
28  import org.apache.struts.validator.ValidatorForm;
29  
30  
31  /***
32   * Form bean for the user type page.
33   *
34  */
35  public final class TypeForm extends ValidatorForm implements Serializable {
36      private String action = null;
37      private String name = null;  //Used to test Multiform per page validation when property name is 'name'
38      private String sByte = null;
39      private String sShort = null;
40      private String sInteger = null;
41      private String sIntRange = null;
42      private String sLong = null;
43      private String sFloat = null;
44      private String sFloatRange = null;
45      private String sDouble = null;
46      private String sDate = null;
47      private String sCreditCard = null;
48      private String sEmail = null;
49      private String sUrl = null;
50      private String sMask = null;
51      private String sMinMaxLength = null;
52      private String sSatisfaction = null;
53      private String[] sOsList = null;
54      private String sOverallSatisfaction = null;
55      private String sWouldRecommend = null;
56      private String[] sUsedLanguages = null;
57  
58      private List lNames = initNames();
59  
60    public String getAction() {
61   return action;
62     }
63  
64     public void setAction(String action) {
65         this.action = action;
66     }
67  
68    public String getName() {
69   return name;
70     }
71  
72     public void setName(String name) {
73         this.name = name;
74     }
75  
76       public String getByte() {
77         return sByte;
78      }
79  
80      public void setByte(String sByte) {
81          this.sByte = sByte;
82      }
83  
84      public String getShort() {
85         return sShort;
86      }
87  
88      public void setShort(String sShort) {
89          this.sShort = sShort;
90      }
91  
92      public String getInteger() {
93         return sInteger;
94      }
95  
96      public void setInteger(String sInteger) {
97          this.sInteger = sInteger;
98      }
99  
100     public String getIntRange() {
101         return sIntRange;
102     }
103 
104     public void setIntRange(String sIntRange) {
105         this.sIntRange = sIntRange;
106     }
107 
108     public String getLong() {
109        return sLong;
110     }
111 
112     public void setLong(String sLong) {
113         this.sLong = sLong;
114     }
115 
116     public String getFloat() {
117        return sFloat;
118     }
119 
120     public void setFloat(String sFloat) {
121         this.sFloat = sFloat;
122     }
123 
124    /***
125     * Float field with range checking
126     * @return
127     */
128     public String getFloatRange() {
129        return sFloatRange;
130     }
131 
132    /***
133     * Float field with range checking
134     * @param sFloatRange
135     */
136     public void setFloatRange(String sFloatRange) {
137           this.sFloatRange = sFloatRange;
138     }
139 
140     public String getDouble() {
141        return sDouble;
142     }
143 
144     public void setDouble(String sDouble) {
145         this.sDouble = sDouble;
146     }
147 
148     public String getDate() {
149        return sDate;
150     }
151 
152     public void setDate(String sDate) {
153         this.sDate = sDate;
154     }
155 
156     public String getCreditCard() {
157        return sCreditCard;
158     }
159 
160     public void setCreditCard(String sCreditCard) {
161         this.sCreditCard = sCreditCard;
162     }
163     public String getMinMaxLength() {
164         return sMinMaxLength;
165     }
166 
167     public void setMinMaxLength(String sMinMaxLength) {
168         this.sMinMaxLength = sMinMaxLength;
169     }
170 
171     public String getUrl() {
172         return sUrl;
173     }
174 
175     public void setUrl(String sUrl) {
176         this.sUrl = sUrl;
177     }
178 
179     public String getEmail() {
180         return sEmail;
181     }
182 
183     public void setEmail(String sEmail) {
184         this.sEmail = sEmail;
185     }
186 
187     public String getMask() {
188         return sMask;
189     }
190 
191     public void setMask(String sMask) {
192         this.sMask = sMask;
193     }
194 
195     public String getSatisfaction() {
196        return sSatisfaction;
197     }
198 
199     public void setSatisfaction(String sSatisfaction) {
200         this.sSatisfaction = sSatisfaction;
201     }
202 
203     public String[] getOsList() {
204        return sOsList;
205     }
206 
207     public void setOsList(String[] anOsList) {
208         this.sOsList = anOsList;
209     }
210 
211     public String getOverallSatisfaction() {
212        return sOverallSatisfaction;
213     }
214 
215     public void setOverallSatisfaction(String anOverallSatisfaction) {
216         this.sOverallSatisfaction = anOverallSatisfaction;
217     }
218 
219     public String getWouldRecommend() {
220        return sWouldRecommend;
221     }
222 
223     public void setWouldRecommend(String anWouldRecommend) {
224         this.sWouldRecommend = anWouldRecommend;
225     }
226 
227     public String[] getUsedLanguages() {
228        return sUsedLanguages;
229     }
230 
231     public void setUsedLanguages(String[] anUsedLanguages) {
232         this.sUsedLanguages = anUsedLanguages;
233     }
234 
235     public List getNameList() {
236        return lNames;
237     }
238 
239     public void setNameList(List lNames) {
240        this.lNames = lNames;
241     }
242 
243     /***
244      * Reset all properties to their default values.
245      *
246      * @param mapping The mapping used to select this instance
247      * @param request The servlet request we are processing
248      */
249     public void reset(ActionMapping mapping, HttpServletRequest request) {
250        String reset = (String)request.getAttribute("typeForm.reset");
251        if ((null != reset)|| ("true".equals(reset))) {
252            action = null;
253            sByte = null;
254            sShort = null;
255            sInteger = null;
256            sIntRange = null;
257            sLong = null;
258            sFloat = null;
259            sFloatRange = null;
260            sDouble = null;
261            sDate = null;
262            sCreditCard = null;
263            sMinMaxLength = null;
264            sEmail = null;
265            sUrl = null;
266            sMask = null;
267            sSatisfaction = null;
268            sOsList = null;
269            sOverallSatisfaction = null;
270            sUsedLanguages = null;
271        }
272        //lNames = initNames();
273     }
274 
275     /***
276      * Initialize list.
277      * @return empty list of LabelValueBeans
278     */
279     private static List initNames() {
280        List lResults = new ArrayList();
281 
282        for (int i = 0; i < 3; i++) {
283           lResults.add(new LabelValueBean(null, null));
284        }
285 
286        return lResults;
287     }
288 }