KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > webapp > admin > service > ServiceForm


1 /*
2  * Copyright 2001,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
18 package org.apache.webapp.admin.service;
19
20 import javax.servlet.http.HttpServletRequest JavaDoc;
21 import org.apache.struts.action.ActionError;
22 import org.apache.struts.action.ActionErrors;
23 import org.apache.struts.action.ActionForm;
24 import org.apache.struts.action.ActionMapping;
25 import java.util.List JavaDoc;
26
27 /**
28  * Form bean for the service page.
29  *
30  * @author Manveen Kaur
31  * @version $Revision: 1.5 $ $Date: 2004/06/28 02:14:51 $
32  */

33
34 public final class ServiceForm extends ActionForm {
35     
36     // ----------------------------------------------------- Instance Variables
37

38
39     /**
40      * The administrative action represented by this form.
41      */

42     private String JavaDoc adminAction = "Edit";
43
44
45     /**
46      * The object name of the Engine this bean refers to.
47      */

48     private String JavaDoc engineObjectName = null;
49
50
51     /**
52      * The object name of the Service this bean refers to.
53      */

54     private String JavaDoc objectName = null;
55
56
57     /**
58      * The text for the serviceName.
59      */

60     private String JavaDoc serviceName = null;
61
62     /**
63      * The text for the serverObjectName.
64      */

65     private String JavaDoc serverObjectName = null;
66     
67    /**
68      * The text for the node label.
69     */

70     private String JavaDoc nodeLabel = null;
71     
72     /**
73      * The text for the engine Name.
74      */

75     private String JavaDoc engineName = null;
76     
77     
78     /**
79      * The name of the service the admin app runs on.
80      */

81     private String JavaDoc adminServiceName = null;
82
83     /**
84      * The text for the defaultHost Name.
85      */

86     private String JavaDoc defaultHost = null;
87     
88     private List JavaDoc hostNameVals = null;
89
90
91     // ------------------------------------------------------------- Properties
92

93
94     /**
95      * Return the administrative action represented by this form.
96      */

97     public String JavaDoc getAdminAction() {
98
99         return this.adminAction;
100
101     }
102
103
104     /**
105      * Set the administrative action represented by this form.
106      */

107     public void setAdminAction(String JavaDoc adminAction) {
108
109         this.adminAction = adminAction;
110
111     }
112
113
114     /**
115      * Return the object name of the Engine this bean refers to.
116      */

117     public String JavaDoc getEngineObjectName() {
118
119         return this.engineObjectName;
120
121     }
122
123
124     /**
125      * Set the object name of the Engine this bean refers to.
126      */

127     public void setEngineObjectName(String JavaDoc engineObjectName) {
128
129         this.engineObjectName = engineObjectName;
130
131     }
132
133
134     /**
135      * Return the object name of the Service this bean refers to.
136      */

137     public String JavaDoc getObjectName() {
138
139         return this.objectName;
140
141     }
142
143
144     /**
145      * Set the object name of the Service this bean refers to.
146      */

147     public void setObjectName(String JavaDoc objectName) {
148
149         this.objectName = objectName;
150
151     }
152
153
154     /**
155      * Return the label of the node that was clicked.
156      */

157     public String JavaDoc getNodeLabel() {
158         
159         return this.nodeLabel;
160         
161     }
162     
163     /**
164      * Set the node label.
165      */

166     public void setNodeLabel(String JavaDoc nodeLabel) {
167         
168         this.nodeLabel = nodeLabel;
169         
170     }
171         
172     /**
173      * Return the host name values.
174      */

175     public List JavaDoc getHostNameVals() {
176         
177         return this.hostNameVals;
178         
179     }
180     
181     /**
182      * Set the hostName values.
183      */

184     public void setHostNameVals(List JavaDoc hostNameVals) {
185         
186         this.hostNameVals = hostNameVals;
187         
188     }
189     
190     /**
191      * Set the engineName.
192      */

193     
194     public void setEngineName(String JavaDoc engineName) {
195         
196         this.engineName = engineName;
197         
198     }
199     
200     
201     /**
202      * Return the engineName.
203      */

204     
205     public String JavaDoc getEngineName() {
206         
207         return this.engineName;
208         
209     }
210     
211     /**
212      * Return the Server ObjectName.
213      */

214     public String JavaDoc getServerObjectName() {
215         
216         return this.serverObjectName;
217         
218     }
219     
220     /**
221      * Set the Server Name.
222      */

223     public void setServerObjectName(String JavaDoc serverObjectName) {
224         
225         this.serverObjectName = serverObjectName;
226         
227     }
228     
229     /**
230      * Return the Service Name.
231      */

232     public String JavaDoc getServiceName() {
233         
234         return this.serviceName;
235         
236     }
237     
238     /**
239      * Set the Service Name.
240      */

241     public void setServiceName(String JavaDoc serviceName) {
242         
243         this.serviceName = serviceName;
244         
245     }
246
247     /**
248      * Return the name of the service the admin app runs on.
249      */

250     public String JavaDoc getAdminServiceName() {
251
252         return this.adminServiceName;
253
254     }
255
256     /**
257      * Set the name of the service the admin app runs on.
258      */

259     public void setAdminServiceName(String JavaDoc adminServiceName) {
260
261         this.adminServiceName = adminServiceName;
262
263     }
264
265     /**
266      * Return the default Host.
267      */

268     public String JavaDoc getDefaultHost() {
269         
270         return this.defaultHost;
271         
272     }
273     
274     /**
275      * Set the default Host.
276      */

277     public void setDefaultHost(String JavaDoc defaultHost) {
278
279         this.defaultHost = defaultHost;
280
281     }
282
283
284     // --------------------------------------------------------- Public Methods
285

286     /**
287      * Reset all properties to their default values.
288      *
289      * @param mapping The mapping used to select this instance
290      * @param request The servlet request we are processing
291      */

292     public void reset(ActionMapping mapping, HttpServletRequest JavaDoc request) {
293         
294         this.engineObjectName = null;
295         this.objectName = null;
296         this.serviceName = null;
297         this.engineName = null;
298         this.adminServiceName = null;
299         this.defaultHost = null;
300     }
301     
302
303     /**
304      * Render this object as a String.
305      */

306     public String JavaDoc toString() {
307
308         StringBuffer JavaDoc sb = new StringBuffer JavaDoc("ServiceForm[adminAction=");
309         sb.append(adminAction);
310         sb.append(",defaultHost=");
311         sb.append(defaultHost);
312         sb.append(",engineName=");
313         sb.append(engineName);
314         sb.append(",engineObjectName='");
315         sb.append(engineObjectName);
316         sb.append("',objectName='");
317         sb.append(objectName);
318         sb.append("',serviceName=");
319         sb.append(serviceName);
320         sb.append("',serverObjectName=");
321         sb.append(serverObjectName);
322         sb.append("',adminServiceName=");
323         sb.append(adminServiceName);
324         sb.append("]");
325         return (sb.toString());
326
327     }
328
329
330     /**
331      * Validate the properties that have been set from this HTTP request,
332      * and return an <code>ActionErrors</code> object that encapsulates any
333      * validation errors that have been found. If no errors are found, return
334      * <code>null</code> or an <code>ActionErrors</code> object with no
335      * recorded error messages.
336      *
337      * @param mapping The mapping used to select this instance
338      * @param request The servlet request we are processing
339      */

340     public ActionErrors validate(ActionMapping mapping,
341     HttpServletRequest JavaDoc request) {
342         
343         ActionErrors errors = new ActionErrors();
344         String JavaDoc submit = request.getParameter("submit");
345         
346         //if (submit != null) {
347

348             if ((serviceName == null) || (serviceName.length() < 1)) {
349                 errors.add("serviceName",
350                            new ActionError("error.serviceName.required"));
351             }
352             
353             if ((engineName == null) || (engineName.length() < 1)) {
354                 errors.add("engineName",
355                            new ActionError("error.engineName.required"));
356             }
357
358         //}
359

360         return errors;
361     }
362     
363 }
364
Popular Tags