KickJava   Java API By Example, From Geeks To Geeks.

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


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: WebAppJettyForm.java,v 1.2 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 WebAppJettyForm extends WebAppForm {
38
39 // --------------------------------------------------------- Properties variables
40

41     private String JavaDoc host = null;
42     private String JavaDoc resourceBase = null;
43     private String JavaDoc displayName = null;
44     private boolean started = false;
45
46 // --------------------------------------------------------- Public Methods
47

48     /**
49      * Reset all properties to their default values.
50      *
51      * @param mapping The mapping used to select this instance
52      * @param request The servlet request we are processing
53      */

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

72     public ActionErrors validate(ActionMapping mapping, HttpServletRequest JavaDoc request) {
73         ActionErrors oErrors = super.validate(mapping, request);
74         return oErrors;
75     }
76
77     /*
78      * Helper method to check that it is a required number and
79      * is a valid integer within the given range. (min, max).
80      *
81      * @param field The field name in the form for which this error occured.
82      * @param numText The string representation of the number.
83      * @param rangeCheck Boolean value set to true of reange check should be performed.
84      *
85      * @param min The lower limit of the range
86      * @param max The upper limit of the range
87      *
88      */

89     public void numberCheck(ActionErrors p_Errors, String JavaDoc field, String JavaDoc numText, boolean rangeCheck
90         , int min, int max) {
91         // Check for 'is required'
92
if ((numText == null) || (numText.length() < 1)) {
93             p_Errors.add(field, new ActionMessage("error.webapp.setting." + field + ".required"));
94         } else {
95
96             // check for 'must be a number' in the 'valid range'
97
try {
98                 int num = Integer.parseInt(numText);
99                 // perform range check only if required
100
if (rangeCheck) {
101                     if ((num < min) || (num > max)) {
102                         p_Errors.add(field
103                             , new ActionMessage("error.webapp.setting." + field + ".range"));
104                     }
105                 }
106             } catch (NumberFormatException JavaDoc e) {
107                 p_Errors.add(field, new ActionMessage("error.webapp.setting." + field + ".format"));
108             }
109         }
110     }
111
112 // --------------------------------------------------------- Properties Methods
113

114     public String JavaDoc getHost() {
115         return host;
116     }
117
118     public void setHost(String JavaDoc host) {
119         this.host = host;
120     }
121
122     public String JavaDoc getResourceBase() {
123         return resourceBase;
124     }
125
126     public void setResourceBase(String JavaDoc resourceBase) {
127         this.resourceBase = resourceBase;
128     }
129
130     public String JavaDoc getDisplayName() {
131         return displayName;
132     }
133
134     public void setDisplayName(String JavaDoc displayName) {
135         this.displayName = displayName;
136     }
137
138     public boolean isStarted() {
139         return started;
140     }
141
142     public void setStarted(boolean started) {
143         this.started = started;
144     }
145 }
Popular Tags