1 20 21 22 package com.fredck.FCKeditor.tags; 23 24 import com.fredck.FCKeditor.FCKeditor; 25 26 import java.io.IOException ; 27 28 import javax.servlet.http.HttpServletRequest ; 29 30 import javax.servlet.jsp.PageContext ; 31 import javax.servlet.jsp.JspException ; 32 import javax.servlet.jsp.JspWriter ; 33 import javax.servlet.jsp.JspTagException ; 34 import javax.servlet.jsp.tagext.BodyContent ; 35 import javax.servlet.jsp.tagext.BodyTagSupport ; 36 37 68 public class FCKeditorTag extends BodyTagSupport { 69 70 private String id; 71 private String value = ""; 72 private String basePath = null; 73 private String toolbarSet = null; 74 private String width = null; 75 private String height = null; 76 private String customConfigurationsPath = null; 77 private String editorAreaCSS = null; 78 private String baseHref = null; 79 private String skinPath = null; 80 private String pluginsPath = null; 81 private String fullPage = null; 82 private String debug = null; 83 private String autoDetectLanguage = null; 84 private String defaultLanguage = null; 85 private String contentLangDirection = null; 86 private String enableXHTML = null; 87 private String enableSourceXHTML = null; 88 private String fillEmptyBlocks = null; 89 private String formatSource = null; 90 private String formatOutput = null; 91 private String formatIndentator = null; 92 private String geckoUseSPAN = null; 93 private String startupFocus = null; 94 private String forcePasteAsPlainText = null; 95 private String forceSimpleAmpersand = null; 96 private String tabSpaces = null; 97 private String useBROnCarriageReturn = null; 98 private String toolbarStartExpanded = null; 99 private String toolbarCanCollapse = null; 100 private String fontColors = null; 101 private String fontNames = null; 102 private String fontSizes = null; 103 private String fontFormats = null; 104 private String stylesXmlPath = null; 105 private String linkBrowserURL = null; 106 private String imageBrowserURL = null; 107 private String flashBrowserURL = null; 108 private String linkUploadURL = null; 109 private String imageUploadURL = null; 110 private String flashUploadURL = null; 111 112 113 114 115 119 protected FCKeditor fcked = null; 120 121 122 127 public void setId(String value) { 128 id=value; 129 } 130 131 136 public void setBasePath(String value) { 137 basePath=value; 138 } 139 140 145 public void setToolbarSet(String value) { 146 toolbarSet=value; 147 } 148 149 154 public void setWidth(String value) { 155 width=value; 156 } 157 158 163 public void setHeight(String value) { 164 height=value; 165 } 166 167 173 public void setCustomConfigurationsPath(String value) { 174 customConfigurationsPath=value; 175 } 176 177 178 184 public void setEditorAreaCSS(String value) { 185 editorAreaCSS=value; 186 } 187 188 189 195 public void setBaseHref(String value) { 196 baseHref=value; 197 } 198 199 200 205 public void setSkinPath(String value) { 206 skinPath=value; 207 } 208 209 210 215 public void setPluginsPath(String value) { 216 pluginsPath=value; 217 } 218 219 220 227 public void setFullPage(String value) throws JspException { 228 if(! value.equals("true") && ! value.equals("false")) 229 throw new JspException ("fullPage attribute can only be true or false"); 230 fullPage=value; 231 } 232 233 234 240 public void setDebug(String value) throws JspException { 241 if(! value.equals("true") && ! value.equals("false")) 242 throw new JspException ("debug attribute can only be true or false"); 243 debug=value; 244 } 245 246 247 255 public void setAutoDetectLanguage(String value) throws JspException { 256 if(! value.equals("true") && ! value.equals("false")) 257 throw new JspException ("autoDetectLanguage attribute can only be true or false: here was " + value); 258 autoDetectLanguage=value; 259 } 260 261 262 268 public void setDefaultLanguage(String value) { 269 defaultLanguage=value; 270 } 271 272 273 284 public void setContentLangDirection(String value) throws JspException { 285 if(! value.equals("true") && ! value.equals("false")) 286 throw new JspException ("debug attribute can only be ltr or rtl"); 287 contentLangDirection=value; 288 } 289 290 291 297 public void setEnableXHTML(String value) throws JspException { 298 if(! value.equals("true") && ! value.equals("false")) 299 throw new JspException ("enableXHTML attribute can only be true or false"); 300 enableXHTML=value; 301 } 302 303 304 310 public void setEnableSourceXHTML(String value) throws JspException { 311 if(! value.equals("true") && ! value.equals("false")) 312 throw new JspException ("enableSourceXHTML attribute can only be true or false"); 313 enableSourceXHTML=value; 314 } 315 316 317 326 public void setFillEmptyBlocks(String value) throws JspException { 327 if(! value.equals("true") && ! value.equals("false")) 328 throw new JspException ("fillEmptyBlocks attribute can only be true or false"); 329 fillEmptyBlocks=value; 330 } 331 332 333 339 public void setFormatSource(String value) throws JspException { 340 if(! value.equals("true") && ! value.equals("false")) 341 throw new JspException ("formatSource attribute can only be true or false"); 342 formatSource=value; 343 } 344 345 346 352 public void setFormatOutput(String value) throws JspException { 353 if(! value.equals("true") && ! value.equals("false")) 354 throw new JspException ("formatOutput attribute can only be true or false"); 355 formatOutput=value; 356 } 357 358 364 public void setFormatIndentator(String value) { 365 formatIndentator=value; 366 } 367 368 369 375 public void setGeckoUseSPAN(String value) throws JspException { 376 if(! value.equals("true") && ! value.equals("false")) 377 throw new JspException ("GeckoUseSPAN attribute can only be true or false"); 378 geckoUseSPAN=value; 379 } 380 381 382 388 public void setStartupFocus(String value) throws JspException { 389 if(! value.equals("true") && ! value.equals("false")) 390 throw new JspException ("startupFocus attribute can only be true or false"); 391 startupFocus=value; 392 } 393 394 395 401 public void setForcePasteAsPlainText(String value) throws JspException { 402 if(! value.equals("true") && ! value.equals("false")) 403 throw new JspException ("forcePasteAsPlainText attribute can only be true or false"); 404 forcePasteAsPlainText=value; 405 } 406 407 408 415 public void setForceSimpleAmpersand(String value) throws JspException { 416 if(! value.equals("true") && ! value.equals("false")) 417 throw new JspException ("forceSimpleAmpersand attribute can only be true or false"); 418 forceSimpleAmpersand=value; 419 } 420 421 422 428 public void setTabSpaces(String value) { 429 tabSpaces=value; 430 } 431 432 433 440 public void setUseBROnCarriageReturn(String value) throws JspException { 441 if(! value.equals("true") && ! value.equals("false")) 442 throw new JspException ("useBROnCarriageReturn attribute can only be true or false"); 443 useBROnCarriageReturn=value; 444 } 445 446 447 453 public void setToolbarStartExpanded(String value) throws JspException { 454 if(! value.equals("true") && ! value.equals("false")) 455 throw new JspException ("ToolbarStartExpanded attribute can only be true or false"); 456 toolbarStartExpanded=value; 457 } 458 459 460 466 public void setToolbarCanCollapse(String value) throws JspException { 467 if(! value.equals("true") && ! value.equals("false")) 468 throw new JspException ("ToolbarCanCollapse attribute can only be true or false"); 469 toolbarCanCollapse=value; 470 } 471 472 473 478 public void setFontColors(String value) { 479 fontColors=value; 480 } 481 482 483 488 public void setFontNames(String value) { 489 fontNames=value; 490 } 491 492 493 498 public void setFontSizes(String value) { 499 fontSizes=value; 500 } 501 502 503 508 public void setFontFormats(String value) { 509 fontFormats=value; 510 } 511 512 513 518 public void setStylesXmlPath(String value) { 519 stylesXmlPath=value; 520 } 521 522 523 529 public void setLinkBrowserURL(String value) { 530 linkBrowserURL=value; 531 } 532 533 534 540 public void setImageBrowserURL(String value) { 541 imageBrowserURL=value; 542 } 543 544 550 public void setFlashBrowserURL(String value) { 551 flashBrowserURL=value; 552 } 553 554 555 561 public void setLinkUploadURL(String value) { 562 linkUploadURL=value; 563 } 564 565 566 572 public void setImageUploadURL(String value) { 573 imageUploadURL=value; 574 } 575 576 577 583 public void setFlashUploadURL(String value) { 584 flashUploadURL=value; 585 } 586 587 588 593 public int doStartTag() throws JspException { 594 fcked=new FCKeditor((HttpServletRequest )pageContext.getRequest(),id); 595 if(toolbarSet!=null) 596 fcked.setToolbarSet(toolbarSet); 597 if(basePath!=null) 598 fcked.setBasePath(basePath); 599 if(width!=null) 600 fcked.setWidth(width); 601 if(height!=null) 602 fcked.setHeight(height); 603 if (customConfigurationsPath != null) 604 fcked.getConfig().put("CustomConfigurationsPath",customConfigurationsPath); 605 if (editorAreaCSS != null) 606 fcked.getConfig().put("EditorAreaCSS",editorAreaCSS); 607 if (baseHref != null) 608 fcked.getConfig().put("BaseHref",baseHref); 609 if (skinPath != null) 610 fcked.getConfig().put("SkinPath",skinPath); 611 if (pluginsPath != null) 612 fcked.getConfig().put("PluginsPath",pluginsPath); 613 if (fullPage != null) 614 fcked.getConfig().put("FullPage",fullPage); 615 if (debug != null) 616 fcked.getConfig().put("Debug",debug); 617 if (autoDetectLanguage != null) 618 fcked.getConfig().put("AutoDetectLanguage",autoDetectLanguage); 619 if (defaultLanguage != null) 620 fcked.getConfig().put("DefaultLanguage",defaultLanguage); 621 if (contentLangDirection != null) 622 fcked.getConfig().put("ContentLangDirection",contentLangDirection); 623 if (enableXHTML != null) 624 fcked.getConfig().put("EnableXHTML",enableXHTML); 625 if (enableSourceXHTML != null) 626 fcked.getConfig().put("EnableSourceXHTML",enableSourceXHTML); 627 if (fillEmptyBlocks != null) 628 fcked.getConfig().put("FillEmptyBlocks",fillEmptyBlocks); 629 if (formatSource != null) 630 fcked.getConfig().put("FormatSource",formatSource); 631 if (formatOutput != null) 632 fcked.getConfig().put("FormatOutput",formatOutput); 633 if (formatIndentator != null) 634 fcked.getConfig().put("FormatIndentator",formatIndentator); 635 if (geckoUseSPAN != null) 636 fcked.getConfig().put("GeckoUseSPAN",geckoUseSPAN); 637 if (startupFocus != null) 638 fcked.getConfig().put("StartupFocus",startupFocus); 639 if (forcePasteAsPlainText != null) 640 fcked.getConfig().put("ForcePasteAsPlainText",forcePasteAsPlainText); 641 if (forceSimpleAmpersand != null) 642 fcked.getConfig().put("ForceSimpleAmpersand",forceSimpleAmpersand); 643 if (tabSpaces != null) 644 fcked.getConfig().put("TabSpaces",tabSpaces); 645 if (useBROnCarriageReturn != null) 646 fcked.getConfig().put("UseBROnCarriageReturn",useBROnCarriageReturn); 647 if (toolbarStartExpanded != null) 648 fcked.getConfig().put("ToolbarStartExpanded",toolbarStartExpanded); 649 if (toolbarCanCollapse != null) 650 fcked.getConfig().put("ToolbarCanCollapse",toolbarCanCollapse); 651 if (fontColors != null) 652 fcked.getConfig().put("FontColors",fontColors); 653 if (fontNames != null) 654 fcked.getConfig().put("FontNames",fontNames); 655 if (fontSizes != null) 656 fcked.getConfig().put("FontSizes",fontSizes); 657 if (fontFormats != null) 658 fcked.getConfig().put("FontFormats",fontFormats); 659 if (stylesXmlPath != null) 660 fcked.getConfig().put("StylesXmlPath",stylesXmlPath); 661 if (linkBrowserURL != null) 662 fcked.getConfig().put("LinkBrowserURL",linkBrowserURL); 663 if (imageBrowserURL != null) 664 fcked.getConfig().put("ImageBrowserURL",imageBrowserURL); 665 if (flashBrowserURL != null) 666 fcked.getConfig().put("FlashBrowserURL",flashBrowserURL); 667 if (linkUploadURL != null) 668 fcked.getConfig().put("LinkUploadURL",linkUploadURL); 669 if (imageUploadURL != null) 670 fcked.getConfig().put("ImageUploadURL",imageUploadURL); 671 if (flashUploadURL != null) 672 fcked.getConfig().put("FlashUploadURL",flashUploadURL); 673 674 return EVAL_BODY_BUFFERED; 675 } 676 677 683 public int doAfterBody() throws JspException { 684 BodyContent body = getBodyContent(); 685 JspWriter writer = body.getEnclosingWriter(); 686 String bodyString = body.getString(); 687 fcked.setValue(bodyString); 688 try { 689 writer.println(fcked.create()); 690 }catch(IOException ioe) { 691 throw new JspException ("Error: IOException while writing to the user"); 692 } 693 694 return SKIP_BODY; 695 } 696 697 } | Popular Tags |