JtmServiceForm.java

00001 
00026 package org.objectweb.jonas.webapp.jonasadmin.service.jtm;
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.ActionForm;
00033 import org.apache.struts.action.ActionMapping;
00034 
00039 public final class JtmServiceForm extends ActionForm {
00040 
00041 // ------------------------------------------------------------- Properties Variables
00042 
00043     private String action = null;
00044     private String timeOutText = null;
00045     private String jtmHost = null;
00046     private String jtmLocation = null;
00047     private String jtmPort = null;
00048 
00049 // ------------------------------------------------------------- Properties Methods
00050 
00051     public String getTimeOutText() {
00052         return timeOutText;
00053     }
00054     public void setTimeOutText(String timeOutText) {
00055         this.timeOutText = timeOutText;
00056     }
00057     public String getJtmHost() {
00058         return jtmHost;
00059     }
00060     public void setJtmHost(String jtmHost) {
00061         this.jtmHost = jtmHost;
00062     }
00063     public String getJtmLocation() {
00064         return jtmLocation;
00065     }
00066     public void setJtmLocation(String jtmLocation) {
00067         this.jtmLocation = jtmLocation;
00068     }
00069     public String getJtmPort() {
00070         return jtmPort;
00071     }
00072     public void setJtmPort(String jtmPort) {
00073         this.jtmPort = jtmPort;
00074     }
00075     public String getAction() {
00076         return action;
00077     }
00078     public void setAction(String action) {
00079         this.action = action;
00080     }
00081 // ------------------------------------------------------------- Public Methods
00082 
00089     public void reset(ActionMapping mapping, HttpServletRequest request) {
00090         action = "apply";
00091     }
00092 
00103     public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
00104         ActionErrors oErrors = new ActionErrors();
00105         numberCheck(oErrors, "timeOut", timeOutText, false, 0, 0);
00106         return oErrors;
00107     }
00108 
00119     public void numberCheck(ActionErrors p_Errors, String field, String numText, boolean rangeCheck
00120         , int min, int max) {
00121         // Check for 'is required'
00122         if ((numText == null) || (numText.length() < 1)) {
00123             p_Errors.add(field, new ActionError("error.jtm." + field + ".required"));
00124         }
00125         else {
00126             // check for 'must be a number' in the 'valid range'
00127             try {
00128                 int num = Integer.parseInt(numText);
00129                 // perform range check only if required
00130                 if (rangeCheck) {
00131                     if ((num < min) || (num > max)) {
00132                         p_Errors.add(field
00133                             , new ActionError("error.jtm." + field + ".range"));
00134                     }
00135                 }
00136             }
00137             catch (NumberFormatException e) {
00138                 p_Errors.add(field, new ActionError("error.jtm." + field + ".format"));
00139             }
00140         }
00141     }
00142 
00143 }

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