KickJava   Java API By Example, From Geeks To Geeks.

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


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 /**
30  * Form bean for the individual resource link page.
31  *
32  * @author Amy Roh
33  * @version $Revision: 1.4 $ $Date: 2004/02/27 14:59:04 $
34  * @since 4.1
35  */

36
37 public final class ResourceLinkForm extends BaseForm {
38
39
40     // ----------------------------------------------------- Instance Variables
41

42
43     // ------------------------------------------------------------- Properties
44

45
46     /**
47      * The name of the resource link.
48      */

49     private String JavaDoc name = null;
50
51     public String JavaDoc getName() {
52         return (this.name);
53     }
54
55     public void setName(String JavaDoc name) {
56         this.name = name;
57     }
58
59     /**
60      * The global name of the resource link.
61      */

62     private String JavaDoc global = null;
63
64     public String JavaDoc getGlobal() {
65         return (this.global);
66     }
67
68     public void setGlobal(String JavaDoc global) {
69         this.global = global;
70     }
71     
72     /**
73      * The resource type of this resource link.
74      */

75     private String JavaDoc resourcetype = null;
76     
77     /**
78      * Return the resource type of the resource link this bean refers to.
79      */

80     public String JavaDoc getResourcetype() {
81         return this.resourcetype;
82     }
83
84     /**
85      * Set the resource type of the resource link this bean refers to.
86      */

87     public void setResourcetype(String JavaDoc resourcetype) {
88         this.resourcetype = resourcetype;
89     }
90        
91     /**
92      * The path of this resource link.
93      */

94     private String JavaDoc path = null;
95     
96     /**
97      * Return the path of the resource link this bean refers to.
98      */

99     public String JavaDoc getPath() {
100         return this.path;
101     }
102
103     /**
104      * Set the path of the resource link this bean refers to.
105      */

106     public void setPath(String JavaDoc path) {
107         this.path = path;
108     }
109        
110     /**
111      * The host of this resource link.
112      */

113     private String JavaDoc host = null;
114     
115     /**
116      * Return the host of the resource link this bean refers to.
117      */

118     public String JavaDoc getHost() {
119         return this.host;
120     }
121
122     /**
123      * Set the host of the resource link this bean refers to.
124      */

125     public void setHost(String JavaDoc host) {
126         this.host = host;
127     }
128     
129        
130     /**
131      * The domain of this resource link.
132      */

133     private String JavaDoc domain = null;
134     
135     /**
136      * Return the domain of the resource link this bean refers to.
137      */

138     public String JavaDoc getDomain() {
139         return this.domain;
140     }
141
142     /**
143      * Set the domain of the resource link this bean refers to.
144      */

145     public void setDomain(String JavaDoc domain) {
146         this.domain = domain;
147     }
148     
149     /**
150      * The type of the resource link link.
151      */

152     private String JavaDoc type = null;
153
154     public String JavaDoc getType() {
155         return (this.type);
156     }
157
158     public void setType(String JavaDoc type) {
159         this.type = type;
160     }
161
162     // --------------------------------------------------------- Public Methods
163

164     /**
165      * Reset all properties to their default values.
166      *
167      * @param mapping The mapping used to select this instance
168      * @param request The servlet request we are processing
169      */

170     public void reset(ActionMapping mapping, HttpServletRequest JavaDoc request) {
171
172         super.reset(mapping, request);
173         name = null;
174         global = null;
175         type = null;
176     }
177
178     /**
179      * Validate the properties that have been set from this HTTP request,
180      * and return an <code>ActionErrors</code> object that encapsulates any
181      * validation errors that have been found. If no errors are found, return
182      * <code>null</code> or an <code>ActionErrors</code> object with no
183      * recorded error messages.
184      *
185      * @param mapping The mapping used to select this instance
186      * @param request The servlet request we are processing
187      */

188     
189     private ActionErrors errors = null;
190     
191     public ActionErrors validate(ActionMapping mapping,
192     HttpServletRequest JavaDoc request) {
193         errors = new ActionErrors();
194
195         String JavaDoc submit = request.getParameter("submit");
196
197         //if (submit != null) {
198

199             // name is a required field
200
if ((name == null) || (name.length() < 1)) {
201                 errors.add("name",
202                            new ActionError("resources.error.name.required"));
203             }
204
205             // global is a required field
206
if (( global == null) || (global.length() < 1)) {
207                 errors.add("global",
208                            new ActionError("resources.error.global.required"));
209             }
210             
211             // type is a required field
212
if ((type == null) || (type.length() < 1)) {
213                 errors.add("type",
214                            new ActionError("resources.error.type.required"));
215             }
216             
217          //}
218

219         return (errors);
220
221     }
222  
223     
224 }
225
Popular Tags