001: /*
002: * JOnAS: Java(TM) Open Application Server
003: * Copyright (C) 1999 Bull S.A.
004: * Contact: jonas-team@objectweb.org
005: *
006: * This library is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU Lesser General Public
008: * License as published by the Free Software Foundation; either
009: * version 2.1 of the License, or any later version.
010: *
011: * This library is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * Lesser General Public License for more details.
015: *
016: * You should have received a copy of the GNU Lesser General Public
017: * License along with this library; if not, write to the Free Software
018: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
019: * USA
020: *
021: * --------------------------------------------------------------------------
022: * $Id: WebAppJettyForm.java 6599 2005-04-21 08:59:54Z kemlerp $
023: * --------------------------------------------------------------------------
024: */
025:
026: package org.objectweb.jonas.webapp.jonasadmin.service.container;
027:
028: import javax.servlet.http.HttpServletRequest;
029:
030: import org.apache.struts.action.ActionMessage;
031: import org.apache.struts.action.ActionErrors;
032: import org.apache.struts.action.ActionMapping;
033:
034: /**
035: * @author Michel-Ange ANTON
036: */
037: public class WebAppJettyForm extends WebAppForm {
038:
039: // --------------------------------------------------------- Properties variables
040:
041: private String host = null;
042: private String resourceBase = null;
043: private String displayName = null;
044: private boolean started = false;
045:
046: // --------------------------------------------------------- Public Methods
047:
048: /**
049: * Reset all properties to their default values.
050: *
051: * @param mapping The mapping used to select this instance
052: * @param request The servlet request we are processing
053: */
054:
055: public void reset(ActionMapping mapping, HttpServletRequest request) {
056: super .reset(mapping, request);
057:
058: started = false;
059: }
060:
061: /**
062: * Validate the properties that have been set from this HTTP request,
063: * and return an <code>ActionErrors</code> object that encapsulates any
064: * validation errors that have been found. If no errors are found, return
065: * <code>null</code> or an <code>ActionErrors</code> object with no
066: * recorded error messages.
067: *
068: * @param mapping The mapping used to select this instance
069: * @param request The servlet request we are processing
070: * @return List of errors
071: */
072: public ActionErrors validate(ActionMapping mapping,
073: HttpServletRequest request) {
074: ActionErrors oErrors = super .validate(mapping, request);
075: return oErrors;
076: }
077:
078: /*
079: * Helper method to check that it is a required number and
080: * is a valid integer within the given range. (min, max).
081: *
082: * @param field The field name in the form for which this error occured.
083: * @param numText The string representation of the number.
084: * @param rangeCheck Boolean value set to true of reange check should be performed.
085: *
086: * @param min The lower limit of the range
087: * @param max The upper limit of the range
088: *
089: */
090: public void numberCheck(ActionErrors p_Errors, String field,
091: String numText, boolean rangeCheck, int min, int max) {
092: // Check for 'is required'
093: if ((numText == null) || (numText.length() < 1)) {
094: p_Errors.add(field, new ActionMessage(
095: "error.webapp.setting." + field + ".required"));
096: } else {
097:
098: // check for 'must be a number' in the 'valid range'
099: try {
100: int num = Integer.parseInt(numText);
101: // perform range check only if required
102: if (rangeCheck) {
103: if ((num < min) || (num > max)) {
104: p_Errors.add(field, new ActionMessage(
105: "error.webapp.setting." + field
106: + ".range"));
107: }
108: }
109: } catch (NumberFormatException e) {
110: p_Errors.add(field, new ActionMessage(
111: "error.webapp.setting." + field + ".format"));
112: }
113: }
114: }
115:
116: // --------------------------------------------------------- Properties Methods
117:
118: public String getHost() {
119: return host;
120: }
121:
122: public void setHost(String host) {
123: this .host = host;
124: }
125:
126: public String getResourceBase() {
127: return resourceBase;
128: }
129:
130: public void setResourceBase(String resourceBase) {
131: this .resourceBase = resourceBase;
132: }
133:
134: public String getDisplayName() {
135: return displayName;
136: }
137:
138: public void setDisplayName(String displayName) {
139: this .displayName = displayName;
140: }
141:
142: public boolean isStarted() {
143: return started;
144: }
145:
146: public void setStarted(boolean started) {
147: this.started = started;
148: }
149: }
|