KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jonas > webapp > jonasadmin > service > container > WebAppForm


1 /*
2  * JOnAS: Java(TM) Open Application Server
3  * Copyright (C) 1999 Bull S.A.
4  * Contact: jonas-team@objectweb.org
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19  * USA
20  *
21  * --------------------------------------------------------------------------
22  * $Id: WebAppForm.java,v 1.5 2005/04/21 08:59:54 kemlerp Exp $
23  * --------------------------------------------------------------------------
24  */

25
26 package org.objectweb.jonas.webapp.jonasadmin.service.container;
27
28 import java.util.List JavaDoc;
29
30 import javax.servlet.http.HttpServletRequest JavaDoc;
31
32 import org.apache.struts.action.ActionMessage;
33 import org.apache.struts.action.ActionErrors;
34 import org.apache.struts.action.ActionForm;
35 import org.apache.struts.action.ActionMapping;
36 import org.objectweb.jonas.webapp.jonasadmin.Jlists;
37
38
39 /**
40  * @author Michel-Ange ANTON
41  */

42 public class WebAppForm extends ActionForm {
43
44 // --------------------------------------------------------- Properties variables
45

46     private String JavaDoc action = "edit";
47     private boolean save = false;
48     private String JavaDoc pathContext = null;
49     private String JavaDoc labelPathContext = null;
50     private List JavaDoc booleanValues = Jlists.getBooleanValues();
51     private String JavaDoc objectName = null;
52     private String JavaDoc j2eeApplication = null;
53     private String JavaDoc j2eeServer = null;
54     private String JavaDoc name = null;
55
56 // --------------------------------------------------------- Public Methods
57

58     /**
59      * Reset all properties to their default values.
60      *
61      * @param mapping The mapping used to select this instance
62      * @param request The servlet request we are processing
63      */

64
65     public void reset(ActionMapping mapping, HttpServletRequest JavaDoc request) {
66         action = "edit";
67         save = false;
68     }
69
70     /**
71      * Validate the properties that have been set from this HTTP request,
72      * and return an <code>ActionErrors</code> object that encapsulates any
73      * validation errors that have been found. If no errors are found, return
74      * <code>null</code> or an <code>ActionErrors</code> object with no
75      * recorded error messages.
76      *
77      * @param mapping The mapping used to select this instance
78      * @param request The servlet request we are processing
79      * @return List of errors
80      */

81     public ActionErrors validate(ActionMapping mapping, HttpServletRequest JavaDoc request) {
82         ActionErrors oErrors = new ActionErrors();
83         // Path context
84
if (getPathContext().length() == 0) {
85             oErrors.add("context", new ActionMessage("error.webapp.context.required"));
86         }
87         return oErrors;
88     }
89
90 // --------------------------------------------------------- Properties Methods
91

92     public String JavaDoc getPathContext() {
93         return pathContext;
94     }
95
96     public void setPathContext(String JavaDoc pathContext) {
97         this.pathContext = pathContext;
98         if (pathContext.length() > 0) {
99             if (pathContext.charAt(0) != '/') {
100                 this.pathContext = "/" + pathContext;
101             }
102         }
103         setLabelPathContext(WebAppItem.extractLabelPathContext(this.pathContext));
104     }
105
106     public String JavaDoc getAction() {
107         return action;
108     }
109
110     public void setAction(String JavaDoc action) {
111         this.action = action;
112     }
113
114     public List JavaDoc getBooleanValues() {
115         return booleanValues;
116     }
117
118     public String JavaDoc getLabelPathContext() {
119         return labelPathContext;
120     }
121
122     public void setLabelPathContext(String JavaDoc labelPathContext) {
123         this.labelPathContext = labelPathContext;
124     }
125
126     public boolean isSave() {
127         return save;
128     }
129
130     public void setSave(boolean save) {
131         this.save = save;
132     }
133
134     public String JavaDoc getObjectName() {
135         return objectName;
136     }
137
138     public void setObjectName(String JavaDoc objectName) {
139         this.objectName = objectName;
140     }
141
142     public String JavaDoc getJ2eeApplication() {
143         return j2eeApplication;
144     }
145
146     public void setJ2eeApplication(String JavaDoc j2eeApplication) {
147         this.j2eeApplication = j2eeApplication;
148     }
149
150     public String JavaDoc getJ2eeServer() {
151         return j2eeServer;
152     }
153
154     public void setJ2eeServer(String JavaDoc j2eeServer) {
155         this.j2eeServer = j2eeServer;
156     }
157
158     public String JavaDoc getName() {
159         return name;
160     }
161
162     public void setName(String JavaDoc name) {
163         this.name = name;
164    }
165
166 }
Popular Tags