1 58 package org.apache.ecs.html; 59 60 import org.apache.ecs.*; 61 62 69 public class Input extends SinglePartElement implements Printable, 70 FormEvents, PageEvents, FocusEvents, MouseEvents, KeyEvents 71 { 72 73 public static final String TEXT = "TEXT"; 74 75 public static final String PASSWORD = "PASSWORD"; 76 77 public static final String CHECKBOX = "CHECKBOX"; 78 79 public static final String RADIO = "RADIO"; 80 81 public static final String FILE = "FILE"; 82 83 public static final String BUTTON = "BUTTON"; 84 85 public static final String IMAGE = "IMAGE"; 86 87 public static final String HIDDEN = "HIDDEN"; 88 89 public static final String SUBMIT = "SUBMIT"; 90 91 public static final String RESET = "RESET"; 92 93 94 public static final String text = "text"; 95 96 public static final String password = "password"; 97 98 public static final String checkbox = "checkbox"; 99 100 public static final String radio = "radio"; 101 102 public static final String file = "file"; 103 104 public static final String button = "button"; 105 106 public static final String image = "image"; 107 108 public static final String hidden = "hidden"; 109 110 public static final String submit = "submit"; 111 112 public static final String reset = "reset"; 113 114 117 { 118 setElementType("input"); 119 } 120 121 125 public Input() 126 { 127 } 128 129 136 public Input(String type) 137 { 138 setType(type); 139 } 140 141 149 public Input(String type, String name) 150 { 151 setType(type); 152 setName(name); 153 } 154 155 164 public Input(String type, String name, String value) 165 { 166 setType(type); 167 setName(name); 168 setValue(value); 169 } 170 171 180 public Input(String type, String name, int value) 181 { 182 setType(type); 183 setName(name); 184 setValue(value); 185 } 186 187 196 public Input(String type, String name, Integer value) 197 { 198 setType(type); 199 setName(name); 200 setValue(value); 201 } 202 203 212 public Input(String type, String name, double value) 213 { 214 setType(type); 215 setName(name); 216 setValue(value); 217 } 218 219 223 public Input setType(String type) 224 { 225 addAttribute("type",type); 226 return this; 227 } 228 229 233 public Input setSrc(String src) 234 { 235 addAttribute("src",src); 236 return this; 237 } 238 239 243 public Input setBorder(int border) 244 { 245 addAttribute("border", Integer.toString(border)); 246 return this; 247 } 248 249 253 public Input setAlt(String alt) 254 { 255 addAttribute("alt",alt); 256 return this; 257 } 258 259 263 public Input setName(String name) 264 { 265 addAttribute("name",name); 266 return this; 267 } 268 269 273 public Input setValue(String value) 274 { 275 addAttribute("value",value); 276 return this; 277 } 278 279 283 public Input setValue(int value) 284 { 285 addAttribute("value",Integer.toString(value)); 286 return this; 287 } 288 289 293 public Input setValue(Integer value) 294 { 295 addAttribute("value",value.toString()); 296 return this; 297 } 298 299 303 public Input setValue(double value) 304 { 305 addAttribute("value",Double.toString(value)); 306 return this; 307 } 308 309 313 public Input setAccept(String accept) 314 { 315 addAttribute("accept",accept); 316 return this; 317 } 318 319 323 public Input setSize(String size) 324 { 325 addAttribute("size",size); 326 return this; 327 } 328 329 333 public Input setSize(int size) 334 { 335 setSize(Integer.toString(size)); 336 return this; 337 } 338 339 343 public Input setMaxlength(String maxlength) 344 { 345 addAttribute("maxlength",maxlength); 346 return this; 347 } 348 349 353 public Input setMaxlength(int maxlength) 354 { 355 setMaxlength(Integer.toString(maxlength)); 356 return this; 357 } 358 359 363 public Input setUsemap(String usemap) 364 { 365 addAttribute("usemap",usemap); 366 return this; 367 } 368 369 373 public Input setTabindex(String index) 374 { 375 addAttribute("tabindex",index); 376 return this; 377 } 378 379 383 public Input setTabindex(int index) 384 { 385 setTabindex(Integer.toString(index)); 386 return this; 387 } 388 389 393 public Input setChecked(boolean checked) 394 { 395 if ( checked == true ) 396 addAttribute("checked", NO_ATTRIBUTE_VALUE); 397 else 398 removeAttribute("checked"); 399 400 return(this); 401 } 402 403 407 public Input setReadOnly(boolean readonly) 408 { 409 if ( readonly == true ) 410 addAttribute("readonly", NO_ATTRIBUTE_VALUE); 411 else 412 removeAttribute("readonly"); 413 414 return(this); 415 } 416 417 421 public Input setDisabled(boolean disabled) 422 { 423 if ( disabled == true ) 424 addAttribute("disabled", NO_ATTRIBUTE_VALUE); 425 else 426 removeAttribute("disabled"); 427 428 return(this); 429 } 430 431 436 public Input addElement(String hashcode,Element element) 437 { 438 addElementToRegistry(hashcode,element); 439 return(this); 440 } 441 442 447 public Input addElement(String hashcode,String element) 448 { 449 addElementToRegistry(hashcode,element); 450 return(this); 451 } 452 456 public Input addElement(Element element) 457 { 458 addElementToRegistry(element); 459 return(this); 460 } 461 462 466 public Input addElement(String element) 467 { 468 addElementToRegistry(element); 469 return(this); 470 } 471 475 public Input removeElement(String hashcode) 476 { 477 removeElementFromRegistry(hashcode); 478 return(this); 479 } 480 481 487 public void setOnSubmit(String script) 488 { 489 addAttribute ( "onSubmit", script ); 490 } 491 492 498 public void setOnReset(String script) 499 { 500 addAttribute ( "onReset", script ); 501 } 502 503 509 public void setOnSelect(String script) 510 { 511 addAttribute ( "onSelect", script ); 512 } 513 514 521 public void setOnChange(String script) 522 { 523 addAttribute ( "onChange", script ); 524 } 525 526 533 public void setOnLoad(String script) 534 { 535 addAttribute ( "onLoad", script ); 536 } 537 538 545 public void setOnUnload(String script) 546 { 547 addAttribute ( "onUnload", script ); 548 } 549 550 558 public void setOnFocus(String script) 559 { 560 addAttribute ( "onFocus", script ); 561 } 562 563 570 public void setOnBlur(String script) 571 { 572 addAttribute ( "onBlur", script ); 573 } 574 575 581 public void setOnClick(String script) 582 { 583 addAttribute ( "onClick", script ); 584 } 585 591 public void setOnDblClick(String script) 592 { 593 addAttribute ( "onDblClick", script ); 594 } 595 601 public void setOnMouseDown(String script) 602 { 603 addAttribute ( "onMouseDown", script ); 604 } 605 611 public void setOnMouseUp(String script) 612 { 613 addAttribute ( "onMouseUp", script ); 614 } 615 621 public void setOnMouseOver(String script) 622 { 623 addAttribute ( "onMouseOver", script ); 624 } 625 631 public void setOnMouseMove(String script) 632 { 633 addAttribute ( "onMouseMove", script ); 634 } 635 641 public void setOnMouseOut(String script) 642 { 643 addAttribute ( "onMouseOut", script ); 644 } 645 646 652 public void setOnKeyPress(String script) 653 { 654 addAttribute ( "onKeyPress", script ); 655 } 656 657 663 public void setOnKeyDown(String script) 664 { 665 addAttribute ( "onKeyDown", script ); 666 } 667 668 674 public void setOnKeyUp(String script) 675 { 676 addAttribute ( "onKeyUp", script ); 677 } 678 } 679 | Popular Tags |