Coverage Report - net.fckeditor.tags.EditorTag
 
Classes in this File Line Coverage Branch Coverage Complexity
EditorTag
0%
0/23
N/A
0
 
 1  
 /*
 2  
  * FCKeditor - The text editor for Internet - http://www.fckeditor.net
 3  
  * Copyright (C) 2003-2008 Frederico Caldeira Knabben
 4  
  * 
 5  
  * == BEGIN LICENSE ==
 6  
  * 
 7  
  * Licensed under the terms of any of the following licenses at your
 8  
  * choice:
 9  
  * 
 10  
  *  - GNU General Public License Version 2 or later (the "GPL")
 11  
  *    http://www.gnu.org/licenses/gpl.html
 12  
  * 
 13  
  *  - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
 14  
  *    http://www.gnu.org/licenses/lgpl.html
 15  
  * 
 16  
  *  - Mozilla Public License Version 1.1 or later (the "MPL")
 17  
  *    http://www.mozilla.org/MPL/MPL-1.1.html
 18  
  * 
 19  
  * == END LICENSE ==
 20  
  */
 21  
 
 22  
 package net.fckeditor.tags;
 23  
 
 24  
 import java.io.IOException;
 25  
 import java.util.Map;
 26  
 
 27  
 import javax.servlet.http.HttpServletRequest;
 28  
 import javax.servlet.jsp.JspException;
 29  
 import javax.servlet.jsp.JspWriter;
 30  
 import javax.servlet.jsp.tagext.TagSupport;
 31  
 
 32  
 import net.fckeditor.FCKeditor;
 33  
 
 34  
 /**
 35  
  * FCKeditor Tag class to access the
 36  
  * {@linkplain net.fckeditor.FCKeditor container}.
 37  
  * 
 38  
  * @version $Id: EditorTag.java 2151 2008-07-02 22:03:15Z mosipov $
 39  
  */
 40  0
 public class EditorTag extends TagSupport {
 41  
 
 42  
         private static final long serialVersionUID = -173091731589866140L;
 43  
 
 44  
         private String instanceName;
 45  
         private String width;
 46  
         private String height;
 47  
         private String toolbarSet;
 48  
         private String value;
 49  
         private String basePath;
 50  
 
 51  
         /** The underlying FCKeditor object */
 52  
         private FCKeditor fckEditor;
 53  
 
 54  
         /**
 55  
          * Sets the name for the given editor instance
 56  
          * 
 57  
          * @param instanceName
 58  
          *            some name without whitespaces
 59  
          */
 60  
         public void setInstanceName(String instanceName) {
 61  0
                 this.instanceName = instanceName;
 62  0
         }
 63  
 
 64  
         /**
 65  
          * Sets the width of the textarea
 66  
          * 
 67  
          * @param width
 68  
          *            width of the editor instance
 69  
          * 
 70  
          */
 71  
         public void setWidth(String width) {
 72  0
                 this.width = width;
 73  0
         }
 74  
 
 75  
         /**
 76  
          * Sets the height of the textarea
 77  
          * 
 78  
          * @param height
 79  
          *            height of the editor instance
 80  
          */
 81  
         public void setHeight(String height) {
 82  0
                 this.height = height;
 83  0
         }
 84  
 
 85  
         /**
 86  
          * Sets the name of the toolbar to display
 87  
          * 
 88  
          * @param toolbarSet
 89  
          *            toolbar set of the editor instance
 90  
          */
 91  
         public void setToolbarSet(String toolbarSet) {
 92  0
                 this.toolbarSet = toolbarSet;
 93  0
         }
 94  
 
 95  
         /**
 96  
          * Sets the editor document content
 97  
          * 
 98  
          * @param value
 99  
          *            any HTML string
 100  
          */
 101  
         public void setValue(String value) {
 102  0
                 this.value = value;
 103  0
         }
 104  
 
 105  
         /**
 106  
          * Sets the dir where the FCKeditor files reside on the server
 107  
          * 
 108  
          * @param basePath
 109  
          *            basePath of the editor instance (e.g. /fckeditor)
 110  
          */
 111  
         public void setBasePath(String basePath) {
 112  0
                 this.basePath = basePath;
 113  0
         }
 114  
 
 115  
         void setConfigParamAll(Map<String, String> map) {
 116  0
                 fckEditor.getConfig().putAll(map);
 117  0
         }
 118  
 
 119  
         /**
 120  
          * Initializes the FCKeditor container and sets attributes
 121  
          * 
 122  
          * @return EVAL_BODY_INCLUDE
 123  
          */
 124  
         public int doStartTag() throws JspException {
 125  0
                 fckEditor = new FCKeditor(
 126  
                                 (HttpServletRequest) pageContext.getRequest(), instanceName,
 127  
                                 width, height, toolbarSet, value, basePath);
 128  
 
 129  0
                 return EVAL_BODY_INCLUDE;
 130  
         }
 131  
 
 132  
         @Override
 133  
         public int doEndTag() throws JspException {
 134  
 
 135  0
                 JspWriter out = pageContext.getOut();
 136  
 
 137  
                 try {
 138  0
                         out.println(fckEditor);
 139  0
                 } catch (IOException e) {
 140  0
                         throw new JspException("Tag response could not be written to the user!",e);
 141  0
                 }
 142  
 
 143  0
                 return EVAL_PAGE;
 144  
         }
 145  
 
 146  
 }