1 58 package org.apache.ecs.html; 59 60 import org.apache.ecs.*; 61 62 69 public class Form extends MultiPartElement implements Printable, FormEvents, MouseEvents, KeyEvents 70 { 71 public static final String GET = "GET"; 72 public static final String get = "get"; 73 public static final String POST = "POST"; 74 public static final String post = "post"; 75 76 public static final String ENC_DEFAULT = "application/x-www-form-urlencoded"; 77 public static final String ENC_UPLOAD = "multipart/form-data"; 78 79 82 { 83 setElementType("form"); 84 setEncType ( ENC_DEFAULT ); 85 setAcceptCharset("UNKNOWN"); 86 } 87 88 92 public Form() 93 { 94 } 95 96 102 public Form(Element element) 103 { 104 addElement(element); 105 } 106 107 113 public Form(String action) 114 { 115 setAction(action); 116 } 117 118 125 public Form(String action, Element element) 126 { 127 addElement(element); 128 setAction(action); 129 } 130 131 139 public Form(String action, String method, Element element) 140 { 141 addElement(element); 142 setAction(action); 143 setMethod(method); 144 } 145 146 153 public Form(String action, String method) 154 { 155 setAction(action); 156 setMethod(method); 157 } 158 159 167 public Form(String action, String method, String enctype) 168 { 169 setAction(action); 170 setMethod(method); 171 setEncType(enctype); 172 } 173 174 178 public Form setAction(String action) 179 { 180 addAttribute("action",action); 181 return this; 182 } 183 184 188 public Form setMethod(String method) 189 { 190 addAttribute("method",method); 191 return this; 192 } 193 194 198 public Form setEncType(String enctype) 199 { 200 addAttribute("enctype",enctype); 201 return this; 202 } 203 204 208 public Form setAccept(String accept) 209 { 210 addAttribute("accept",accept); 211 return this; 212 } 213 214 218 public Form setName(String name) 219 { 220 addAttribute("name",name); 221 return this; 222 } 223 224 228 public Form setTarget(String target) 229 { 230 addAttribute("target",target); 231 return this; 232 } 233 234 238 public Form setAcceptCharset(String acceptcharset) 239 { 240 addAttribute("accept-charset",acceptcharset); 241 return this; 242 } 243 244 249 public Form addElement(String hashcode,Element element) 250 { 251 addElementToRegistry(hashcode,element); 252 return(this); 253 } 254 255 260 public Form addElement(String hashcode,String element) 261 { 262 addElementToRegistry(hashcode,element); 263 return(this); 264 } 265 266 270 public Form addElement(Element element) 271 { 272 addElementToRegistry(element); 273 return(this); 274 } 275 276 280 public Form addElement(String element) 281 { 282 addElementToRegistry(element); 283 return(this); 284 } 285 289 public Form removeElement(String hashcode) 290 { 291 removeElementFromRegistry(hashcode); 292 return(this); 293 } 294 295 301 public void setOnSubmit(String script) 302 { 303 addAttribute ( "onSubmit", script ); 304 } 305 306 312 public void setOnReset(String script) 313 { 314 addAttribute ( "onReset", script ); 315 } 316 317 323 public void setOnSelect(String script) 324 { 325 addAttribute ( "onSelect", script ); 326 } 327 328 335 public void setOnChange(String script) 336 { 337 addAttribute ( "onChange", script ); 338 } 339 340 346 public void setOnClick(String script) 347 { 348 addAttribute ( "onClick", script ); 349 } 350 356 public void setOnDblClick(String script) 357 { 358 addAttribute ( "onDblClick", script ); 359 } 360 366 public void setOnMouseDown(String script) 367 { 368 addAttribute ( "onMouseDown", script ); 369 } 370 376 public void setOnMouseUp(String script) 377 { 378 addAttribute ( "onMouseUp", script ); 379 } 380 386 public void setOnMouseOver(String script) 387 { 388 addAttribute ( "onMouseOver", script ); 389 } 390 396 public void setOnMouseMove(String script) 397 { 398 addAttribute ( "onMouseMove", script ); 399 } 400 406 public void setOnMouseOut(String script) 407 { 408 addAttribute ( "onMouseOut", script ); 409 } 410 411 417 public void setOnKeyPress(String script) 418 { 419 addAttribute ( "onKeyPress", script ); 420 } 421 422 428 public void setOnKeyDown(String script) 429 { 430 addAttribute ( "onKeyDown", script ); 431 } 432 433 439 public void setOnKeyUp(String script) 440 { 441 addAttribute ( "onKeyUp", script ); 442 } 443 } 444 | Popular Tags |