1 25 26 package org.objectweb.jonas.webapp.jonasadmin.service.jtm; 27 28 import javax.servlet.http.HttpServletRequest ; 29 30 import org.apache.struts.action.ActionMessage; 31 import org.apache.struts.action.ActionErrors; 32 import org.apache.struts.action.ActionForm; 33 import org.apache.struts.action.ActionMapping; 34 35 39 public final class JtmServiceForm extends ActionForm { 40 41 43 private String action = null; 44 private String timeOutText = null; 45 private String jtmHost = null; 46 private String jtmLocation = null; 47 private String jtmPort = null; 48 49 51 public String getTimeOutText() { 52 return timeOutText; 53 } 54 public void setTimeOutText(String timeOutText) { 55 this.timeOutText = timeOutText; 56 } 57 public String getJtmHost() { 58 return jtmHost; 59 } 60 public void setJtmHost(String jtmHost) { 61 this.jtmHost = jtmHost; 62 } 63 public String getJtmLocation() { 64 return jtmLocation; 65 } 66 public void setJtmLocation(String jtmLocation) { 67 this.jtmLocation = jtmLocation; 68 } 69 public String getJtmPort() { 70 return jtmPort; 71 } 72 public void setJtmPort(String jtmPort) { 73 this.jtmPort = jtmPort; 74 } 75 public String getAction() { 76 return action; 77 } 78 public void setAction(String action) { 79 this.action = action; 80 } 81 83 89 public void reset(ActionMapping mapping, HttpServletRequest request) { 90 action = "apply"; 91 } 92 93 103 public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) { 104 ActionErrors oErrors = new ActionErrors(); 105 numberCheck(oErrors, "timeOut", timeOutText, false, 0, 0); 106 return oErrors; 107 } 108 109 119 public void numberCheck(ActionErrors p_Errors, String field, String numText, boolean rangeCheck 120 , int min, int max) { 121 if ((numText == null) || (numText.length() < 1)) { 123 p_Errors.add(field, new ActionMessage("error.jtm." + field + ".required")); 124 } else { 125 try { 127 int num = Integer.parseInt(numText); 128 if (rangeCheck) { 130 if ((num < min) || (num > max)) { 131 p_Errors.add(field 132 , new ActionMessage("error.jtm." + field + ".range")); 133 } 134 } 135 } catch (NumberFormatException e) { 136 p_Errors.add(field, new ActionMessage("error.jtm." + field + ".format")); 137 } 138 } 139 } 140 141 } 142 | Popular Tags |