1 58 package org.apache.ecs.html; 59 60 import org.apache.ecs.*; 61 62 110 public class Option extends MultiPartElement implements Printable, FocusEvents, FormEvents, MouseEvents, KeyEvents 111 112 { 113 114 117 { 118 setElementType("option"); 119 setNeedClosingTag(true); 120 } 121 122 127 public Option() 128 { 129 } 130 131 138 public Option(String value) 139 { 140 setValue(value); 141 } 142 143 151 public Option(String label, String value) 152 { 153 setLabel(label); 154 setValue(value); 155 } 156 157 165 public Option(String label, int value) 166 { 167 setLabel(label); 168 setValue(value); 169 } 170 171 179 public Option(String label, double value) 180 { 181 setLabel(label); 182 setValue(value); 183 } 184 185 194 public Option(String label, String value, String text) 195 { 196 this(label,value); 197 addElement(text); 198 } 199 200 209 public Option(String label, int value, String text) 210 { 211 this(label,value); 212 addElement(text); 213 } 214 215 224 public Option(String label, double value, String text) 225 { 226 this(label,value); 227 addElement(text); 228 } 229 230 234 public Option setLabel(String label) 235 { 236 addAttribute("label",label); 237 return this; 238 } 239 240 243 public String getLabel() 244 { 245 return getAttribute("label"); 246 } 247 248 252 public Option setValue(String value) 253 { 254 addAttribute("value",value); 255 return this; 256 } 257 258 262 public Option setValue(int value) 263 { 264 addAttribute("value",Integer.toString(value)); 265 return this; 266 } 267 268 272 public Option setValue(double value) 273 { 274 addAttribute("value",Double.toString(value)); 275 return this; 276 } 277 278 281 public String getValue() 282 { 283 return getAttribute("value"); 284 } 285 286 290 public Option setSelected(boolean selected) 291 { 292 if ( selected == true ) 293 addAttribute("selected", NO_ATTRIBUTE_VALUE); 294 else 295 removeAttribute("selected"); 296 297 return(this); 298 } 299 300 304 public boolean getSelected() 305 { 306 if ( hasAttribute("selected")) 307 { 308 return true; 309 } else { 310 return false; 311 } 312 } 313 314 318 public Option setDisabled(boolean disabled) 319 { 320 if ( disabled == true ) 321 addAttribute("disabled", NO_ATTRIBUTE_VALUE); 322 else 323 removeAttribute("disabled"); 324 325 return(this); 326 } 327 328 332 public boolean getDisabled() 333 { 334 if ( hasAttribute("disabled")) 335 { 336 return true; 337 } else { 338 return false; 339 } 340 } 341 342 347 public Option addElement(String hashcode,Element element) 348 { 349 addElementToRegistry(hashcode,element); 350 return(this); 351 } 352 353 358 public Option addElement(String hashcode,String element) 359 { 360 addElementToRegistry(hashcode,element); 361 return(this); 362 } 363 364 368 public Option addElement(Element element) 369 { 370 addElementToRegistry(element); 371 return(this); 372 } 373 374 378 public Option addElement(String element) 379 { 380 addElementToRegistry(element); 381 return(this); 382 } 383 384 388 public Option[] addElement(String [] element) 389 { 390 Option[] option = new Option[element.length]; 391 for(int x = 0; x < element.length; x++) 392 { 393 option[x]= new Option().addElement(element[x]); 394 } 395 return(option); 396 } 397 398 402 public Option removeElement(String hashcode) 403 { 404 removeElementFromRegistry(hashcode); 405 return(this); 406 } 407 408 416 public void setOnFocus(String script) 417 { 418 addAttribute ( "onFocus", script ); 419 } 420 421 428 public void setOnBlur(String script) 429 { 430 addAttribute ( "onBlur", script ); 431 } 432 433 439 public void setOnSubmit(String script) 440 { 441 addAttribute ( "onSubmit", script ); 442 } 443 444 450 public void setOnReset(String script) 451 { 452 addAttribute ( "onReset", script ); 453 } 454 455 461 public void setOnSelect(String script) 462 { 463 addAttribute ( "onSelect", script ); 464 } 465 466 473 public void setOnChange(String script) 474 { 475 addAttribute ( "onChange", script ); 476 } 477 478 484 public void setOnClick(String script) 485 { 486 addAttribute ( "onClick", script ); 487 } 488 494 public void setOnDblClick(String script) 495 { 496 addAttribute ( "onDblClick", script ); 497 } 498 504 public void setOnMouseDown(String script) 505 { 506 addAttribute ( "onMouseDown", script ); 507 } 508 514 public void setOnMouseUp(String script) 515 { 516 addAttribute ( "onMouseUp", script ); 517 } 518 524 public void setOnMouseOver(String script) 525 { 526 addAttribute ( "onMouseOver", script ); 527 } 528 534 public void setOnMouseMove(String script) 535 { 536 addAttribute ( "onMouseMove", script ); 537 } 538 544 public void setOnMouseOut(String script) 545 { 546 addAttribute ( "onMouseOut", script ); 547 } 548 549 555 public void setOnKeyPress(String script) 556 { 557 addAttribute ( "onKeyPress", script ); 558 } 559 560 566 public void setOnKeyDown(String script) 567 { 568 addAttribute ( "onKeyDown", script ); 569 } 570 571 577 public void setOnKeyUp(String script) 578 { 579 addAttribute ( "onKeyUp", script ); 580 } 581 } 582 | Popular Tags |