WebAppJettyForm.java

00001 /*
00002  * JOnAS: Java(TM) Open Application Server
00003  * Copyright (C) 1999 Bull S.A.
00004  * Contact: jonas-team@objectweb.org
00005  *
00006  * This library is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU Lesser General Public
00008  * License as published by the Free Software Foundation; either
00009  * version 2.1 of the License, or any later version.
00010  *
00011  * This library is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  * Lesser General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU Lesser General Public
00017  * License along with this library; if not, write to the Free Software
00018  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
00019  * USA
00020  *
00021  * --------------------------------------------------------------------------
00022  * $Id: WebAppJettyForm.java,v 1.1 2003/09/23 14:53:03 antonma Exp $
00023  * --------------------------------------------------------------------------
00024  */
00025 
00026 package org.objectweb.jonas.webapp.jonasadmin.service.container;
00027 
00028 import javax.servlet.http.HttpServletRequest;
00029 
00030 import org.apache.struts.action.ActionError;
00031 import org.apache.struts.action.ActionErrors;
00032 import org.apache.struts.action.ActionMapping;
00033 
00037 public class WebAppJettyForm extends WebAppForm {
00038 
00039 // --------------------------------------------------------- Properties variables
00040 
00041     private String host = null;
00042     private String resourceBase = null;
00043     private String displayName = null;
00044     private boolean started = false;
00045 
00046 // --------------------------------------------------------- Public Methods
00047 
00055     public void reset(ActionMapping mapping, HttpServletRequest request) {
00056         super.reset(mapping, request);
00057 
00058         started = false;
00059     }
00060 
00072     public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
00073         ActionErrors oErrors = super.validate(mapping, request);
00074         return oErrors;
00075     }
00076 
00077     /*
00078      * Helper method to check that it is a required number and
00079      * is a valid integer within the given range. (min, max).
00080      *
00081      * @param  field  The field name in the form for which this error occured.
00082      * @param  numText  The string representation of the number.
00083      * @param rangeCheck  Boolean value set to true of reange check should be performed.
00084      *
00085      * @param  min  The lower limit of the range
00086      * @param  max  The upper limit of the range
00087      *
00088      */
00089     public void numberCheck(ActionErrors p_Errors, String field, String numText, boolean rangeCheck
00090         , int min, int max) {
00091         // Check for 'is required'
00092         if ((numText == null) || (numText.length() < 1)) {
00093             p_Errors.add(field, new ActionError("error.webapp.setting." + field + ".required"));
00094         }
00095         else {
00096 
00097             // check for 'must be a number' in the 'valid range'
00098             try {
00099                 int num = Integer.parseInt(numText);
00100                 // perform range check only if required
00101                 if (rangeCheck) {
00102                     if ((num < min) || (num > max)) {
00103                         p_Errors.add(field
00104                             , new ActionError("error.webapp.setting." + field + ".range"));
00105                     }
00106                 }
00107             }
00108             catch (NumberFormatException e) {
00109                 p_Errors.add(field, new ActionError("error.webapp.setting." + field + ".format"));
00110             }
00111         }
00112     }
00113 
00114 // --------------------------------------------------------- Properties Methods
00115 
00116     public String getHost() {
00117         return host;
00118     }
00119 
00120     public void setHost(String host) {
00121         this.host = host;
00122     }
00123 
00124     public String getResourceBase() {
00125         return resourceBase;
00126     }
00127 
00128     public void setResourceBase(String resourceBase) {
00129         this.resourceBase = resourceBase;
00130     }
00131 
00132     public String getDisplayName() {
00133         return displayName;
00134     }
00135 
00136     public void setDisplayName(String displayName) {
00137         this.displayName = displayName;
00138     }
00139 
00140     public boolean isStarted() {
00141         return started;
00142     }
00143 
00144     public void setStarted(boolean started) {
00145         this.started = started;
00146     }
00147 }

Generated on Tue Feb 15 15:05:31 2005 for JOnAS by  doxygen 1.3.9.1