KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jmanage > webui > forms > ApplicationForm


1 /**
2  * Copyright 2004-2005 jManage.org
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 package org.jmanage.webui.forms;
17
18 import org.apache.struts.action.ActionErrors;
19 import org.apache.struts.action.ActionMapping;
20 import org.apache.struts.action.ActionError;
21 import org.jmanage.core.config.*;
22 import org.jmanage.core.util.ErrorCodes;
23 import org.jmanage.webui.validator.Validator;
24
25 import javax.servlet.http.HttpServletRequest JavaDoc;
26
27 /**
28  *
29  * date: Jun 25, 2004
30  * @author Rakesh Kalra, Shashank Bellary
31  */

32 public class ApplicationForm extends BaseForm {
33
34     public static final String JavaDoc FORM_PASSWORD = "$$$$$$$$";
35
36     private String JavaDoc appId;
37     private String JavaDoc name;
38     private String JavaDoc host;
39     private String JavaDoc port;
40     private String JavaDoc url;
41     private String JavaDoc username;
42     private String JavaDoc password;
43     private String JavaDoc type;
44
45     // jsr160 only
46
private String JavaDoc jndiFactory;
47     private String JavaDoc jndiURL;
48
49     public String JavaDoc getApplicationId() {
50         return appId;
51     }
52
53     public void setApplicationId(String JavaDoc appId) {
54         this.appId = appId;
55     }
56
57     public String JavaDoc getName() {
58         return name;
59     }
60
61     public void setName(String JavaDoc name) {
62         this.name = name;
63     }
64
65     public String JavaDoc getHost() {
66         return host;
67     }
68
69     public void setHost(String JavaDoc host) {
70         this.host = host;
71     }
72
73     public String JavaDoc getPort() {
74         return port;
75     }
76
77     public void setPort(String JavaDoc port) {
78         this.port = port;
79     }
80
81     public String JavaDoc getURL() {
82         return url;
83     }
84
85     public void setURL(String JavaDoc url) {
86         this.url = url;
87     }
88
89     public String JavaDoc getUsername() {
90         return username;
91     }
92
93     public void setUsername(String JavaDoc username) {
94         this.username = username;
95     }
96
97     public String JavaDoc getPassword() {
98         return password;
99     }
100
101     public void setPassword(String JavaDoc password) {
102         this.password = password;
103     }
104
105     public String JavaDoc getType() {
106         return type;
107     }
108
109     public void setType(String JavaDoc type) {
110         this.type = type;
111     }
112
113     public void setJndiFactory(String JavaDoc jndiFactory){
114         if(jndiFactory != null && jndiFactory.length() > 0)
115             this.jndiFactory = jndiFactory;
116     }
117
118     public String JavaDoc getJndiFactory(){
119         return jndiFactory;
120     }
121
122     public void setJndiURL(String JavaDoc jndiURL){
123         if(jndiURL != null && jndiURL.length() > 0)
124             this.jndiURL = jndiURL;
125     }
126
127     public String JavaDoc getJndiURL(){
128         return jndiURL;
129     }
130
131     public ActionErrors validate(ActionMapping mapping, HttpServletRequest JavaDoc request){
132         ActionErrors errors = super.validate(mapping, request);
133         if(errors==null || errors.isEmpty()){
134             if(name.indexOf("/") != -1){
135                 errors.add(ActionErrors.GLOBAL_ERROR,
136                         new ActionError(ErrorCodes.INVALID_CHAR_APP_NAME));
137             }
138             ApplicationType appType = ApplicationTypes.getApplicationType(type);
139             MetaApplicationConfig metaAppConfig =
140                     appType.getModule().getMetaApplicationConfig();
141             if(metaAppConfig.isDisplayHost()){
142                 Validator.validateRequired(host, "Host Name", errors);
143             }
144             if(metaAppConfig.isDisplayPort()){
145                 if(Validator.validateRequired(port, "Port Number", errors)){
146                     Validator.validateInteger(port, "Port Number", errors);
147                 }
148             }
149             if(metaAppConfig.isDisplayURL()){
150                 Validator.validateRequired(url, "URL", errors);
151             }
152         }
153         return errors;
154     }
155 }
156
Popular Tags