1 58 package org.apache.ecs.html; 59 60 import org.apache.ecs.*; 61 import java.util.Enumeration; 62 63 74 public class Select extends MultiPartElement implements 75 Printable, PageEvents, FormEvents, MouseEvents, KeyEvents, FocusEvents 76 { 77 80 { 81 setElementType("select"); 82 } 83 87 public Select() 88 { 89 } 90 91 97 public Select(String name) 98 { 99 setName(name); 100 } 101 102 109 public Select(String name, String size) 110 { 111 setName(name); 112 setSize(size); 113 } 114 115 122 public Select(String name, int size) 123 { 124 setName(name); 125 setSize(size); 126 } 127 128 135 public Select(String name, String[] element) 136 { 137 setName(name); 138 addElement(element); 139 } 140 141 148 public Select(String name, Option[] element) 149 { 150 setName(name); 151 addElement(element); 152 } 153 154 159 public Select addElement(String hashcode,Element element) 160 { 161 addElementToRegistry(hashcode,element); 162 return(this); 163 } 164 165 170 public Select addElement(String hashcode,String element) 171 { 172 addElementToRegistry(hashcode,element); 173 return(this); 174 } 175 176 180 public Select addElement(Element element) 181 { 182 addElementToRegistry(element); 183 return(this); 184 } 185 186 190 public Select addElement(Option[] element) 191 { 192 for(int x = 0 ; x < element.length; x++) 193 { 194 addElementToRegistry(element[x]); 195 } 196 return(this); 197 } 198 199 203 public Select addElement(String element) 204 { 205 addElementToRegistry(element); 206 return(this); 207 } 208 209 213 public Select addElement(String[] element) 214 { 215 Option[] option = new Option().addElement(element); 216 addElement(option); 217 return(this); 218 } 219 220 public Select selectOption(int option) 221 { 222 Enumeration enum = keys(); 223 for(int x = 0; enum.hasMoreElements(); x++) 224 { 225 ConcreteElement element = (ConcreteElement)getElement((String)enum.nextElement()); 226 if(x == option) 227 { 228 ((Option)element).setSelected(true); 229 break; 230 } 231 } 232 return this; 233 } 234 235 243 public Select appendOption(String value) 244 { 245 return addElement(new org.apache.ecs.html.Option(value)); 246 } 247 248 257 public Select appendOption(String label,String value) 258 { 259 return addElement(new org.apache.ecs.html.Option(label,value)); 260 } 261 262 271 public Select appendOption(String label,int value) 272 { 273 return addElement(new org.apache.ecs.html.Option(label,value)); 274 } 275 276 285 public Select appendOption(String label,double value) 286 { 287 return addElement(new org.apache.ecs.html.Option(label,value)); 288 } 289 290 300 public Select appendOption(String label,String value,String text) 301 { 302 return addElement(new org.apache.ecs.html.Option(label,value,text)); 303 } 304 305 315 public Select appendOption(String label,int value,String text) 316 { 317 return addElement(new org.apache.ecs.html.Option(label,value,text)); 318 } 319 320 330 public Select appendOption(String label,double value,String text) 331 { 332 return addElement(new org.apache.ecs.html.Option(label,value,text)); 333 } 334 335 339 public Select setName(String name) 340 { 341 addAttribute("name",name); 342 return this; 343 } 344 345 349 public Select setSize(String size) 350 { 351 addAttribute("size",size); 352 return this; 353 } 354 355 359 public Select setSize(int size) 360 { 361 setSize(Integer.toString(size)); 362 return this; 363 } 364 365 369 public Select setMultiple(boolean multiple) 370 { 371 if ( multiple == true ) 372 addAttribute("multiple", NO_ATTRIBUTE_VALUE); 373 else 374 removeAttribute("multiple"); 375 376 return(this); 377 } 378 379 383 public Select setTabindex(String index) 384 { 385 addAttribute("tabindex",index); 386 return this; 387 } 388 389 393 public Select setTabindex(int index) 394 { 395 setTabindex(Integer.toString(index)); 396 return this; 397 } 398 399 403 public Select setDisabled(boolean disabled) 404 { 405 if ( disabled == true ) 406 addAttribute("disabled", NO_ATTRIBUTE_VALUE); 407 else 408 removeAttribute("disabled"); 409 410 return(this); 411 } 412 416 public Select removeElement(String hashcode) 417 { 418 removeElementFromRegistry(hashcode); 419 return(this); 420 } 421 422 429 public void setOnLoad(String script) 430 { 431 addAttribute ( "onLoad", script ); 432 } 433 434 441 public void setOnUnload(String script) 442 { 443 addAttribute ( "onUnload", script ); 444 } 445 446 452 public void setOnSubmit(String script) 453 { 454 addAttribute ( "onSubmit", script ); 455 } 456 457 463 public void setOnReset(String script) 464 { 465 addAttribute ( "onReset", script ); 466 } 467 468 474 public void setOnSelect(String script) 475 { 476 addAttribute ( "onSelect", script ); 477 } 478 479 486 public void setOnChange(String script) 487 { 488 addAttribute ( "onChange", script ); 489 } 490 491 497 public void setOnClick(String script) 498 { 499 addAttribute ( "onClick", script ); 500 } 501 507 public void setOnDblClick(String script) 508 { 509 addAttribute ( "onDblClick", script ); 510 } 511 517 public void setOnMouseDown(String script) 518 { 519 addAttribute ( "onMouseDown", script ); 520 } 521 527 public void setOnMouseUp(String script) 528 { 529 addAttribute ( "onMouseUp", script ); 530 } 531 537 public void setOnMouseOver(String script) 538 { 539 addAttribute ( "onMouseOver", script ); 540 } 541 547 public void setOnMouseMove(String script) 548 { 549 addAttribute ( "onMouseMove", script ); 550 } 551 557 public void setOnMouseOut(String script) 558 { 559 addAttribute ( "onMouseOut", script ); 560 } 561 562 568 public void setOnKeyPress(String script) 569 { 570 addAttribute ( "onKeyPress", script ); 571 } 572 573 579 public void setOnKeyDown(String script) 580 { 581 addAttribute ( "onKeyDown", script ); 582 } 583 584 590 public void setOnKeyUp(String script) 591 { 592 addAttribute ( "onKeyUp", script ); 593 } 594 595 603 public void setOnFocus(String script) 604 { 605 addAttribute ( "onFocus", script ); 606 } 607 608 615 public void setOnBlur(String script) 616 { 617 addAttribute ( "onBlur", script ); 618 } 619 620 } 621 | Popular Tags |