KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > webapp > admin > realm > UserDatabaseRealmForm


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 package org.apache.webapp.admin.realm;
18
19 import javax.servlet.http.HttpServletRequest JavaDoc;
20 import org.apache.struts.action.ActionError;
21 import org.apache.struts.action.ActionErrors;
22 import org.apache.struts.action.ActionForm;
23 import org.apache.struts.action.ActionMapping;
24 import java.net.InetAddress JavaDoc;
25 import java.util.List JavaDoc;
26
27 import org.apache.webapp.admin.ApplicationServlet;
28 import org.apache.webapp.admin.LabelValueBean;
29
30 /**
31  * Form bean for the User Database realm page.
32  *
33  * @author Manveen Kaur
34  * @version $Revision: 1.4 $ $Date: 2004/06/28 02:14:51 $
35  */

36
37 public final class UserDatabaseRealmForm extends RealmForm {
38     
39     // ----------------------------------------------------- Instance Variables
40

41     /**
42      * The text for the resource name.
43      */

44     private String JavaDoc resource = null;
45         
46     // ------------------------------------------------------------- Properties
47

48     
49     /**
50      * Return the resource Name.
51      */

52     public String JavaDoc getResource() {
53         
54         return this.resource;
55         
56     }
57     
58     /**
59      * Set the resource Name.
60      */

61     public void setResource(String JavaDoc resource) {
62         
63         this.resource = resource;
64         
65     }
66         
67     // --------------------------------------------------------- Public Methods
68

69     /**
70      * Reset all properties to their default values.
71      *
72      * @param mapping The mapping used to select this instance
73      * @param request The servlet request we are processing
74      */

75     public void reset(ActionMapping mapping, HttpServletRequest JavaDoc request) {
76         
77         super.reset(mapping, request);
78         this.resource = null;
79         
80     }
81     
82    /**
83      * Render this object as a String.
84      */

85     public String JavaDoc toString() {
86
87         StringBuffer JavaDoc sb = new StringBuffer JavaDoc("UserDatabaseRealmForm[adminAction=");
88         sb.append(getAdminAction());
89         sb.append(",resource=");
90         sb.append(getResource());
91         sb.append("',objectName='");
92         sb.append(getObjectName());
93         sb.append("',realmType=");
94         sb.append(getRealmType());
95         sb.append("]");
96         return (sb.toString());
97
98     }
99
100     /**
101      * Validate the properties that have been set from this HTTP request,
102      * and return an <code>ActionErrors</code> object that encapsulates any
103      * validation errors that have been found. If no errors are found, return
104      * <code>null</code> or an <code>ActionErrors</code> object with no
105      * recorded error messages.
106      *
107      * @param mapping The mapping used to select this instance
108      * @param request The servlet request we are processing
109      */

110     
111     public ActionErrors validate(ActionMapping mapping,
112     HttpServletRequest JavaDoc request) {
113         
114         ActionErrors errors = new ActionErrors();
115         
116         String JavaDoc submit = request.getParameter("submit");
117         
118         // front end validation when save is clicked.
119
//if (submit != null) {
120
if ((resource == null) || (resource.length() < 1)) {
121                 errors.add("resource",
122                 new ActionError("error.resource.required"));
123             }
124         //}
125
return errors;
126     }
127 }
128
Popular Tags