1 21 22 package org.opensubsystems.patterns.dialoglayout.www; 23 24 import javax.servlet.jsp.JspException ; 25 26 import org.opensubsystems.core.www.BlockElementTag; 27 import org.opensubsystems.core.www.TagUtils; 28 import org.opensubsystems.patterns.tabbeddialog.www.TabbedDialogTag; 29 30 65 public class DynamicListTag extends BlockElementTag 66 { 67 69 72 public static final String DEFAULT_CHECK_INDICATOR = "*"; 73 74 77 public static final String CHECK_INDICATOR_ID = "checkindicator"; 78 79 81 84 private static final long serialVersionUID = -3452469590307215632L; 85 86 92 protected String m_strFocus; 93 94 97 protected String m_strDisabled; 98 99 102 protected String m_strSize; 103 104 108 protected String m_strCheck; 109 110 113 protected String m_strCheckLabel; 114 115 120 protected String m_strCheckIdentifier; 121 122 125 protected String m_strListLabel; 126 127 134 protected String m_strBufferName; 135 136 143 protected String m_strRemovedName; 144 145 152 protected String m_strChangedName; 153 154 156 159 public DynamicListTag() 160 { 161 super("clsDynamicList", BlockElementTag.DIV_BLOCK_ELEMENT); 162 163 m_strSize = "7"; 164 m_strDisabled = Boolean.FALSE.toString(); 165 m_strCheck = "false"; 166 m_strCheckLabel = ""; 167 m_strCheckIdentifier = DEFAULT_CHECK_INDICATOR; 168 m_strListLabel = "Added items"; 169 m_strBufferName = ""; 170 m_strRemovedName = ""; 171 m_strChangedName = ""; 172 } 173 174 176 179 public int doStartTag( 180 ) throws JspException 181 { 182 StringBuffer sbHtml = new StringBuffer (); 183 StringBuffer sbJSBuffer = new StringBuffer (); 184 185 String strCurrentId = getCurrentId(); 188 189 StringBuffer sbIdBuffer = new StringBuffer (strCurrentId); 191 int iIdBufferBaseLength; 192 sbIdBuffer.append(m_strId); 193 iIdBufferBaseLength = sbIdBuffer.length(); 194 195 196 247 248 sbHtml.append("<"); 250 sbHtml.append(m_strType); 251 sbHtml.append(" id=\""); 252 sbHtml.append(strCurrentId); 253 sbHtml.append(m_strId); 254 sbHtml.append("control\""); 255 if ((m_strCssclass != null) && (m_strCssclass.length() > 0)) 256 { 257 sbHtml.append(" class=\""); 258 sbHtml.append(m_strCssclass); 259 sbHtml.append("\""); 260 } 261 sbHtml.append(">\n"); 262 263 sbHtml.append("<div class=\"clsDynamicListButtons\">"); 266 sbIdBuffer.delete(iIdBufferBaseLength, sbIdBuffer.length()); 268 sbJSBuffer.delete(0, sbJSBuffer.length()); 269 sbJSBuffer.append("addToDynamicList('"); 270 sbJSBuffer.append(sbIdBuffer); 271 sbJSBuffer.append("dynamiclistinput', '"); 272 sbJSBuffer.append(sbIdBuffer); 273 sbJSBuffer.append("dynamiclistselect', '"); 274 sbJSBuffer.append(sbIdBuffer); 275 sbJSBuffer.append("dynamiclistcheckidentifier', '"); 276 sbJSBuffer.append(sbIdBuffer); 277 sbJSBuffer.append("dynamiclistcheck');collectDataFromDynamicList('"); 278 sbJSBuffer.append(sbIdBuffer); 279 sbJSBuffer.append("dynamiclistselect', '"); 280 sbJSBuffer.append(sbIdBuffer); 281 sbJSBuffer.append("dynamiclistbuffer');"); 282 283 sbIdBuffer.append("dladdbutton"); 284 285 ImageButtonControlTag add = new ImageButtonControlTag(); 286 add.setAccesskey("A"); 287 add.setCssclass("clsImageTextUniformButton clsImageAddButton"); 288 add.setDisabled(getDisabled()); 289 add.setOnclick(sbJSBuffer.toString()); 290 add.setId(sbIdBuffer.toString()); 291 add.setTitle("Add the newly specified item to the list."); 292 add.setPageContext(pageContext); 293 add.doEndTag(sbHtml, "Add"); 294 295 sbIdBuffer.delete(iIdBufferBaseLength, sbIdBuffer.length()); 297 sbJSBuffer.delete(0, sbJSBuffer.length()); 298 sbJSBuffer.append("deleteFromDynamicList('"); 299 sbJSBuffer.append(sbIdBuffer); 300 sbJSBuffer.append("dynamiclistselect', '"); 301 sbJSBuffer.append(sbIdBuffer); 302 sbJSBuffer.append("dynamiclistremoveids', '"); 303 sbJSBuffer.append(sbIdBuffer); 304 sbJSBuffer.append("dynamiclistchangedids');collectDataFromDynamicList('"); 305 sbJSBuffer.append(sbIdBuffer); 306 sbJSBuffer.append("dynamiclistselect', '"); 307 sbJSBuffer.append(sbIdBuffer); 308 sbJSBuffer.append("dynamiclistbuffer');"); 309 310 sbIdBuffer.append("dlremovebutton"); 311 312 ImageButtonControlTag remove = new ImageButtonControlTag(); 313 remove.setAccesskey("R"); 314 remove.setCssclass("clsImageTextUniformButton clsImageRemoveButton"); 315 remove.setDisabled(getDisabled()); 316 remove.setOnclick(sbJSBuffer.toString()); 317 remove.setId(sbIdBuffer.toString()); 318 remove.setTitle("Remove the selected items from the list."); 319 remove.setPageContext(pageContext); 320 remove.doEndTag(sbHtml, "Remove"); 321 322 sbIdBuffer.delete(iIdBufferBaseLength, sbIdBuffer.length()); 324 sbJSBuffer.delete(0, sbJSBuffer.length()); 325 sbJSBuffer.append("moveUpInDynamicList('"); 326 sbJSBuffer.append(sbIdBuffer); 327 sbJSBuffer.append("dynamiclistselect', '"); 328 sbJSBuffer.append(sbIdBuffer); 329 sbJSBuffer.append("dynamiclistchangedids');collectDataFromDynamicList('"); 330 sbJSBuffer.append(sbIdBuffer); 331 sbJSBuffer.append("dynamiclistselect', '"); 332 sbJSBuffer.append(sbIdBuffer); 333 sbJSBuffer.append("dynamiclistbuffer');"); 334 335 sbIdBuffer.append("dlupbutton"); 336 337 ImageButtonControlTag up = new ImageButtonControlTag(); 338 up.setAccesskey("U"); 339 up.setCssclass("clsImageTextUniformButton clsImageMoveOneUpButton"); 340 up.setDisabled(getDisabled()); 341 up.setOnclick(sbJSBuffer.toString()); 342 up.setId(sbIdBuffer.toString()); 343 up.setTitle("Move the selected items in the list up."); 344 up.setPageContext(pageContext); 345 up.doEndTag(sbHtml, "Up"); 346 347 sbIdBuffer.delete(iIdBufferBaseLength, sbIdBuffer.length()); 349 sbJSBuffer.delete(0, sbJSBuffer.length()); 350 sbJSBuffer.append("moveDownInDynamicList('"); 351 sbJSBuffer.append(sbIdBuffer); 352 sbJSBuffer.append("dynamiclistselect', '"); 353 sbJSBuffer.append(sbIdBuffer); 354 sbJSBuffer.append("dynamiclistchangedids');collectDataFromDynamicList('"); 355 sbJSBuffer.append(sbIdBuffer); 356 sbJSBuffer.append("dynamiclistselect', '"); 357 sbJSBuffer.append(sbIdBuffer); 358 sbJSBuffer.append("dynamiclistbuffer');"); 359 360 sbIdBuffer.append("dldownbutton"); 361 362 ImageButtonControlTag down = new ImageButtonControlTag(); 363 down.setAccesskey("D"); 364 down.setCssclass("clsImageTextUniformButton clsImageMoveOneDownButton"); 365 down.setDisabled(getDisabled()); 366 down.setOnclick(sbJSBuffer.toString()); 367 down.setId(sbIdBuffer.toString()); 368 down.setTitle("Move the selected items in the list down."); 369 down.setPageContext(pageContext); 370 down.doEndTag(sbHtml, "Down"); 371 sbHtml.append("</div>\n"); 373 374 sbIdBuffer.delete(iIdBufferBaseLength, sbIdBuffer.length()); 375 376 sbHtml.append("<div class=\"clsDynamicListBody\">\n" + 378 "<div class=\"clsDynamicListAddRow\">" + 379 "<input type=\"text\" id=\""); 381 sbHtml.append(sbIdBuffer); 382 sbHtml.append("dynamiclistinput\" class=\"clsDynamicListInput\">"); 383 if (isCheckboxUsed()) 384 { 385 sbHtml.append(" "); 386 if (getChecklabel().length() > 0) 387 { 388 sbHtml.append(m_strCheckLabel); 390 sbHtml.append(":"); 391 } 392 sbHtml.append("<input type=\"checkbox\" id=\""); 393 sbHtml.append(sbIdBuffer); 394 sbHtml.append("dynamiclistcheck\" class=\"clsDynamicListCheck\">"); 395 } 396 sbHtml.append("</div>\n" + 397 "<div class=\"clsDynamicListLabelRow\">"); 398 sbHtml.append(m_strListLabel); 399 sbHtml.append(":</div>\n" + 400 "<div class=\"clsDynamicListListRow\">\n" + 401 "<select id=\""); 402 sbHtml.append(sbIdBuffer); 403 sbHtml.append("dynamiclistselect\" class=\"clsDynamicListSelect\" size=\""); 404 sbHtml.append(m_strSize); 405 sbHtml.append("\" multiple>\n"); 406 407 TagUtils.write(pageContext, sbHtml.toString()); 408 409 if (isFocusedControl()) 410 { 411 415 sbHtml.delete(0, sbHtml.length()); 418 sbHtml.append(strCurrentId); 419 sbHtml.append(m_strId); 420 421 cache(TabbedDialogTag.FOCUSED_CONTROL_ID, sbHtml.toString()); 422 } 423 424 cache(CHECK_INDICATOR_ID, m_strCheckIdentifier); 427 428 return (EVAL_BODY_INCLUDE); 429 } 430 431 434 public int doEndTag( 435 ) throws JspException 436 { 437 StringBuffer sbHtml = new StringBuffer (); 438 439 String strCurrentId = getCurrentId(); 442 StringBuffer sbIdBuffer = new StringBuffer (strCurrentId); 443 sbIdBuffer.append(m_strId); 444 445 sbHtml.append("</select>\n" + 447 "</div>\n" + 448 "<input type=\"hidden\" value=\"\" id=\""); 449 sbHtml.append(sbIdBuffer); 450 sbHtml.append("dynamiclistbuffer\" name=\""); 451 sbHtml.append(m_strBufferName); 452 sbHtml.append("\">\n"); 453 454 if (isCheckboxUsed()) 457 { 458 sbHtml.append("<input type=\"hidden\" id=\""); 460 sbHtml.append(sbIdBuffer); 461 sbHtml.append("dynamiclistcheckidentifier\" name=\"CHECK_IDENTIFIER\" value=\""); 462 sbHtml.append(m_strCheckIdentifier); 463 sbHtml.append("\">\n"); 464 } 465 466 sbHtml.append("<input type=\"hidden\" value=\"\" id=\""); 468 sbHtml.append(sbIdBuffer); 469 sbHtml.append("dynamiclistremoveids\" name=\""); 470 if ((m_strRemovedName == null) || (m_strRemovedName.length() == 0)) 471 { 472 sbHtml.append(strCurrentId); 473 sbHtml.append(m_strId); 474 sbHtml.append("dynamiclistremoveids"); 475 } 476 else 477 { 478 sbHtml.append(m_strRemovedName); 479 } 480 sbHtml.append("\">\n"); 481 482 sbHtml.append("<input type=\"hidden\" value=\"\" id=\""); 484 sbHtml.append(sbIdBuffer); 485 sbHtml.append("dynamiclistchangedids\" name=\""); 486 if ((m_strChangedName == null) || (m_strChangedName.length() == 0)) 487 { 488 sbHtml.append(strCurrentId); 489 sbHtml.append(m_strId); 490 sbHtml.append("dynamiclistchangedids"); 491 } 492 else 493 { 494 sbHtml.append(m_strChangedName); 495 } 496 sbHtml.append("\">\n" + 497 "</div>" + 498 "</"); 499 sbHtml.append(m_strType); 500 sbHtml.append(">"); 501 TagUtils.write(pageContext, sbHtml.toString()); 502 503 return (EVAL_PAGE); 504 } 505 506 510 public String getFocus() 511 { 512 return m_strFocus; 513 } 514 515 519 public void setFocus( 520 String strFocus 521 ) 522 { 523 m_strFocus = strFocus; 524 } 525 526 530 public void setFocus( 531 boolean bFocus 532 ) 533 { 534 m_strFocus = Boolean.toString(bFocus); 535 } 536 537 541 public boolean isFocusedControl( 542 ) 543 { 544 return ((Boolean.TRUE.toString().equalsIgnoreCase(m_strFocus)) 545 || ("1".equals(m_strFocus))); 546 } 547 548 552 public String getDisabled( 553 ) 554 { 555 return m_strDisabled; 556 } 557 558 562 public void setDisabled( 563 String strDisabled 564 ) 565 { 566 m_strDisabled = strDisabled; 567 } 568 569 573 public void setDisabled( 574 boolean bDisabled 575 ) 576 { 577 m_strDisabled = Boolean.toString(bDisabled); 578 } 579 580 583 public boolean isDisabledControl( 584 ) 585 { 586 return ((Boolean.TRUE.toString().equalsIgnoreCase(m_strDisabled)) 587 || ("1".equals(m_strDisabled))); 588 } 589 590 593 public String getSize( 594 ) 595 { 596 return m_strSize; 597 } 598 599 602 public void setSize( 603 String strSize 604 ) 605 { 606 m_strSize = strSize; 607 } 608 609 613 public String getCheck( 614 ) 615 { 616 return m_strCheck; 617 } 618 619 623 public void setCheck( 624 String strCheck 625 ) 626 { 627 m_strCheck = strCheck; 628 } 629 630 634 public void setCheck( 635 boolean bCheck 636 ) 637 { 638 m_strCheck = Boolean.toString(bCheck); 639 } 640 641 644 public boolean isCheckboxUsed( 645 ) 646 { 647 return ((Boolean.TRUE.toString().equalsIgnoreCase(m_strCheck)) 648 || ("1".equals(m_strCheck))); 649 } 650 651 654 public String getChecklabel() 655 { 656 return m_strCheckLabel; 657 } 658 659 662 public void setChecklabel( 663 String strCheckLabel 664 ) 665 { 666 m_strCheckLabel = strCheckLabel; 667 } 668 669 672 public String getCheckidentifier() 673 { 674 return m_strCheckIdentifier; 675 } 676 677 681 public void setCheckidentifier( 682 String strCheckIdentifier 683 ) 684 { 685 m_strCheckIdentifier = strCheckIdentifier; 686 } 687 688 691 public String getListlabel() 692 { 693 return m_strListLabel; 694 } 695 696 699 public void setListlabel( 700 String strListLabel 701 ) 702 { 703 m_strListLabel = strListLabel; 704 } 705 706 710 public String getBuffername() 711 { 712 return m_strBufferName; 713 } 714 715 719 public void setBuffername( 720 String strBufferName 721 ) 722 { 723 m_strBufferName = strBufferName; 724 } 725 726 730 public String getRemovedname() 731 { 732 return m_strRemovedName; 733 } 734 735 739 public void setRemovedname( 740 String strRemovedName 741 ) 742 { 743 m_strRemovedName = strRemovedName; 744 } 745 746 750 public String getChangedname() 751 { 752 return m_strChangedName; 753 } 754 755 759 public void setChangedname( 760 String strChangedName 761 ) 762 { 763 m_strChangedName = strChangedName; 764 } 765 } 766 | Popular Tags |