KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > webapp > admin > resources > UserDatabaseForm


1 /*
2  * Copyright 2002,2004 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
17 package org.apache.webapp.admin.resources;
18
19 import java.util.List JavaDoc;
20 import java.util.ArrayList JavaDoc;
21
22 import javax.servlet.http.HttpServletRequest JavaDoc;
23 import org.apache.struts.action.ActionError;
24 import org.apache.struts.action.ActionErrors;
25 import org.apache.struts.action.ActionForm;
26 import org.apache.struts.action.ActionMapping;
27 import org.apache.webapp.admin.LabelValueBean;
28
29 import java.lang.reflect.Constructor JavaDoc;
30
31 /**
32  * Form bean for the individual user database page.
33  *
34  * @author Manveen Kaur
35  * @version $Revision: 1.4 $ $Date: 2004/02/27 14:59:04 $
36  * @since 4.1
37  */

38
39 public final class UserDatabaseForm extends BaseForm {
40
41
42     // ----------------------------------------------------- Instance Variables
43

44
45     // ------------------------------------------------------------- Properties
46

47     /**
48      * The domain of this data source.
49      */

50     private String JavaDoc domain = null;
51     
52     /**
53      * Return the domain of the data source this bean refers to.
54      */

55     public String JavaDoc getDomain() {
56         return this.domain;
57     }
58
59     /**
60      * Set the domain of the data source this bean refers to.
61      */

62     public void setDomain(String JavaDoc domain) {
63         this.domain = domain;
64     }
65
66     /**
67      * The name of the associated entry.
68      */

69     private String JavaDoc name = null;
70
71     public String JavaDoc getName() {
72         return (this.name);
73     }
74
75     public void setName(String JavaDoc name) {
76         this.name = name;
77     }
78
79     /**
80      * The path of the associated user database entry.
81      */

82     private String JavaDoc path = null;
83
84     public String JavaDoc getPath() {
85         return (this.path);
86     }
87
88     public void setPath(String JavaDoc path) {
89         this.path = path;
90     }
91
92     /**
93      * The type of the resource.
94      */

95     private String JavaDoc type = null;
96
97     public String JavaDoc getType() {
98         return (this.type);
99     }
100
101     public void setType(String JavaDoc type) {
102         this.type = type;
103     }
104
105     /**
106      * The factory that implements the user database entry.
107      */

108     private String JavaDoc factory = null;
109
110     public String JavaDoc getFactory() {
111         return (this.factory);
112     }
113
114     public void setFactory(String JavaDoc factory) {
115         this.factory = factory;
116     }
117
118     /**
119      * The description of the associated entry.
120      */

121     private String JavaDoc description = null;
122
123     public String JavaDoc getDescription() {
124         return (this.description);
125     }
126
127     public void setDescription(String JavaDoc description) {
128         this.description = description;
129     }
130     
131     // --------------------------------------------------------- Public Methods
132

133     /**
134      * Reset all properties to their default values.
135      *
136      * @param mapping The mapping used to select this instance
137      * @param request The servlet request we are processing
138      */

139     public void reset(ActionMapping mapping, HttpServletRequest JavaDoc request) {
140
141         super.reset(mapping, request);
142         name = null;
143         type = null;
144         path = null;
145         factory = null;
146         description = null;
147
148     }
149
150     /**
151      * Validate the properties that have been set from this HTTP request,
152      * and return an <code>ActionErrors</code> object that encapsulates any
153      * validation errors that have been found. If no errors are found, return
154      * <code>null</code> or an <code>ActionErrors</code> object with no
155      * recorded error messages.
156      *
157      * @param mapping The mapping used to select this instance
158      * @param request The servlet request we are processing
159      */

160     
161     private ActionErrors errors = null;
162     
163     public ActionErrors validate(ActionMapping mapping,
164     HttpServletRequest JavaDoc request) {
165
166         errors = new ActionErrors();
167
168         String JavaDoc submit = request.getParameter("submit");
169         //if (submit != null) {
170

171             // name is a required field
172
if ((name == null) || (name.length() < 1)) {
173                 errors.add("name",
174                            new ActionError("resources.error.name.required"));
175             }
176
177             // path is a required field
178
if ((path == null) || (path.length() < 1)) {
179                 errors.add("path",
180                            new ActionError("resources.error.path.required"));
181             }
182
183             // Quotes not allowed in name
184
if ((name != null) && (name.indexOf('"') >= 0)) {
185                 errors.add("name",
186                            new ActionError("users.error.quotes"));
187             }
188
189             // Quotes not allowed in path
190
if ((path != null) && (path.indexOf('"') > 0)) {
191                 errors.add("path",
192                            new ActionError("users.error.quotes"));
193             }
194
195             // Quotes not allowed in description
196
if ((description != null) && (description.indexOf('"') > 0)) {
197                 errors.add("description",
198                            new ActionError("users.error.quotes"));
199             }
200         //}
201
return (errors);
202     }
203     
204 }
205
Popular Tags