KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > webapp > admin > host > AliasForm


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.host;
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 alias page.
29  *
30  * @author Manveen Kaur
31  * @version $Revision: 1.3 $ $Date: 2004/02/27 14:59:03 $
32  */

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

38     /**
39      * The text for the hostName.
40      */

41     private String JavaDoc hostName = null;
42
43     /**
44      * The text for the aliasName.
45      */

46     private String JavaDoc aliasName = null;
47
48     /*
49      * Represent aliases as a List.
50      */

51     private List JavaDoc aliasVals = null;
52    
53     // ------------------------------------------------------------- Properties
54

55     /**
56      * Return the host name.
57      */

58     public String JavaDoc getHostName() {
59         
60         return this.hostName;
61         
62     }
63     
64     /**
65      * Set the host name.
66      */

67     public void setHostName(String JavaDoc hostName) {
68         
69         this.hostName = hostName;
70         
71     }
72
73     /**
74      * Return the alias name.
75      */

76     public String JavaDoc getAliasName() {
77         
78         return this.aliasName;
79         
80     }
81     
82     /**
83      * Set the alias name.
84      */

85     public void setAliasName(String JavaDoc aliasName) {
86         
87         this.aliasName = aliasName;
88         
89     }
90
91     /**
92      * Return the List of alias Vals.
93      */

94     public List JavaDoc getAliasVals() {
95         
96         return this.aliasVals;
97         
98     }
99     
100     /**
101      * Set the alias Vals.
102      */

103     public void setAliasVals(List JavaDoc aliasVals) {
104         
105         this.aliasVals = aliasVals;
106         
107     }
108     
109     // --------------------------------------------------------- Public Methods
110

111     /**
112      * Reset all properties to their default values.
113      *
114      * @param mapping The mapping used to select this instance
115      * @param request The servlet request we are processing
116      */

117     public void reset(ActionMapping mapping, HttpServletRequest JavaDoc request) {
118         
119         this.aliasName = null;
120         this.hostName = null;
121
122     }
123     
124      /**
125      * Render this object as a String.
126      */

127     public String JavaDoc toString() {
128
129         StringBuffer JavaDoc sb = new StringBuffer JavaDoc("AliasForm[hostName=");
130         sb.append(hostName);
131         sb.append("]");
132         return (sb.toString());
133
134     }
135
136     /**
137      * Validate the properties that have been set from this HTTP request,
138      * and return an <code>ActionErrors</code> object that encapsulates any
139      * validation errors that have been found. If no errors are found, return
140      * <code>null</code> or an <code>ActionErrors</code> object with no
141      * recorded error messages.
142      *
143      * @param mapping The mapping used to select this instance
144      * @param request The servlet request we are processing
145      */

146     
147     public ActionErrors validate(ActionMapping mapping,
148     HttpServletRequest JavaDoc request) {
149         
150         ActionErrors errors = new ActionErrors();
151         
152         String JavaDoc submit = request.getParameter("submit");
153         
154         // front end validation when save is clicked.
155
//if (submit != null) {
156

157             // aliasName cannot be null
158
if ((aliasName== null) || (aliasName.length() < 1)) {
159                 errors.add("aliasName", new ActionError("error.aliasName.required"));
160             }
161                         
162         //}
163
return errors;
164     }
165     
166 }
167
Popular Tags