1 16 17 package org.apache.webapp.admin.server; 18 19 20 import javax.servlet.http.HttpServletRequest ; 21 import org.apache.struts.action.ActionError; 22 import org.apache.struts.action.ActionErrors; 23 import org.apache.struts.action.ActionForm; 24 import org.apache.struts.action.ActionMapping; 25 import org.apache.webapp.admin.ApplicationServlet; 26 import org.apache.webapp.admin.TomcatTreeBuilder; 27 28 import java.util.List ; 29 30 36 37 public final class ServerForm extends ActionForm { 38 39 41 44 private String nodeLabel = null; 45 46 49 private String portNumberText = "8080"; 50 51 54 private String shutdownText = null; 55 56 59 private String objectName = null; 60 61 65 public String getNodeLabel() { 66 67 return this.nodeLabel; 68 69 } 70 71 74 public void setNodeLabel(String nodeLabel) { 75 76 this.nodeLabel = nodeLabel; 77 78 } 79 80 83 public String getPortNumberText() { 84 85 return this.portNumberText; 86 87 } 88 89 92 public void setPortNumberText(String portNumberText) { 93 94 this.portNumberText = portNumberText; 95 96 } 97 98 101 public String getShutdownText() { 102 103 return this.shutdownText; 104 105 } 106 107 110 public void setShutdownText(String shutdownText) { 111 112 this.shutdownText = shutdownText; 113 114 } 115 116 119 public String getObjectName() { 120 121 return this.objectName; 122 123 } 124 125 126 129 public void setObjectName(String objectName) { 130 131 this.objectName = objectName; 132 133 } 134 135 137 143 public void reset(ActionMapping mapping, HttpServletRequest request) { 144 145 this.portNumberText = null; 146 this.shutdownText = null; 147 148 } 149 150 151 161 public ActionErrors validate(ActionMapping mapping, 162 HttpServletRequest request) { 163 164 ActionErrors errors = new ActionErrors(); 165 166 String submit = request.getParameter("submit"); 167 169 172 if ((portNumberText == null) || (portNumberText.length() < 1)) { 173 errors.add("portNumberText", 174 new ActionError("error.portNumber.required")); 175 } else { 176 try { 177 int port = Integer.parseInt(portNumberText); 178 if ((port <= 0) || (port >65535 )) 179 errors.add("portNumberText", 180 new ActionError("error.portNumber.range")); 181 } catch (NumberFormatException e) { 182 errors.add("portNumberText", 183 new ActionError("error.portNumber.format")); 184 } 185 } 186 187 189 if ((shutdownText == null) || (shutdownText.length() < 7)) 190 errors.add("shutdownText", 191 new ActionError("error.shutdownText.length")); 192 193 195 return errors; 196 197 } 198 199 } 200 | Popular Tags |