KickJava   Java API By Example, From Geeks To Geeks.

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


1 /**
2  * JOnAS: Java(TM) Open Application Server
3  * Copyright (C) 2003-2004 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: WebAppCatalinaForm.java,v 1.7 2005/04/21 08:59:54 kemlerp Exp $
23  * --------------------------------------------------------------------------
24  */

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

37 public class WebAppCatalinaForm extends WebAppForm {
38
39 // --------------------------------------------------------- Properties variables
40

41     private String JavaDoc host = null;
42     private boolean cookies = false;
43     private boolean reloadable = false;
44     private boolean swallowOutput = false;
45     private boolean crossContext = false;
46     private boolean override = false;
47     private String JavaDoc docBase = null;
48     private int state = 0;
49
50 // --------------------------------------------------------- Public Methods
51

52     /**
53      * Reset all properties to their default values.
54      *
55      * @param mapping The mapping used to select this instance
56      * @param request The servlet request we are processing
57      */

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

80     public ActionErrors validate(ActionMapping mapping, HttpServletRequest JavaDoc request) {
81         ActionErrors oErrors = super.validate(mapping, request);
82         //numberCheck(oErrors, "sessionTimeout", sessionTimeout, true, 1, 65535);
83
return oErrors;
84     }
85
86     /*
87      * Helper method to check that it is a required number and
88      * is a valid integer within the given range. (min, max).
89      *
90      * @param field The field name in the form for which this error occured.
91      * @param numText The string representation of the number.
92      * @param rangeCheck Boolean value set to true of reange check should be performed.
93      *
94      * @param min The lower limit of the range
95      * @param max The upper limit of the range
96      *
97      */

98     public void numberCheck(ActionErrors p_Errors, String JavaDoc field, String JavaDoc numText, boolean rangeCheck
99         , int min, int max) {
100         // Check for 'is required'
101
if ((numText == null) || (numText.length() < 1)) {
102             p_Errors.add(field, new ActionMessage("error.webapp.setting." + field + ".required"));
103         } else {
104
105             // check for 'must be a number' in the 'valid range'
106
try {
107                 int num = Integer.parseInt(numText);
108                 // perform range check only if required
109
if (rangeCheck) {
110                     if ((num < min) || (num > max)) {
111                         p_Errors.add(field
112                             , new ActionMessage("error.webapp.setting." + field + ".range"));
113                     }
114                 }
115             } catch (NumberFormatException JavaDoc e) {
116                 p_Errors.add(field, new ActionMessage("error.webapp.setting." + field + ".format"));
117             }
118         }
119     }
120
121 // --------------------------------------------------------- Properties Methods
122
/*
123     public boolean isAvailable() {
124         return available;
125     }
126
127     public void setAvailable(boolean available) {
128         this.available = available;
129     }
130 */

131     public boolean isCookies() {
132         return cookies;
133     }
134
135     public void setCookies(boolean cookies) {
136         this.cookies = cookies;
137     }
138
139     public boolean isReloadable() {
140         return reloadable;
141     }
142
143     public void setReloadable(boolean reloadable) {
144         this.reloadable = reloadable;
145     }
146
147     public boolean isSwallowOutput() {
148         return swallowOutput;
149     }
150
151     public void setSwallowOutput(boolean swallowOutput) {
152         this.swallowOutput = swallowOutput;
153     }
154
155     public String JavaDoc getHost() {
156         return host;
157     }
158
159     public void setHost(String JavaDoc host) {
160         this.host = host;
161     }
162
163     public boolean isCrossContext() {
164         return crossContext;
165     }
166
167     public void setCrossContext(boolean crossContext) {
168         this.crossContext = crossContext;
169     }
170
171     public String JavaDoc getDocBase() {
172         return docBase;
173     }
174
175     public void setDocBase(String JavaDoc docBase) {
176         this.docBase = docBase;
177     }
178
179     public boolean isOverride() {
180         return override;
181     }
182
183     public void setOverride(boolean override) {
184         this.override = override;
185     }
186     public int getState() {
187         return state;
188     }
189
190     public void setState(int state) {
191         this.state = state;
192     }
193
194
195 }
Popular Tags