KickJava   Java API By Example, From Geeks To Geeks.

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


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.util.List JavaDoc;
25 import java.util.Enumeration JavaDoc;
26
27 import org.apache.webapp.admin.ApplicationServlet;
28 import org.apache.webapp.admin.LabelValueBean;
29
30 /**
31  * Form bean for the memory 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 MemoryRealmForm extends RealmForm {
38     
39     // ----------------------------------------------------- Instance Variables
40

41     /**
42      * The text for the path Name.
43      */

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

48     /**
49      * Return the path Name.
50      */

51     public String JavaDoc getPathName() {
52         
53         return this.pathName;
54         
55     }
56     
57     /**
58      * Set the path Name.
59      */

60     public void setPathName(String JavaDoc pathName) {
61         
62         this.pathName = pathName;
63         
64     }
65         
66     // --------------------------------------------------------- Public Methods
67

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

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

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

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