1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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
36
37
38
39
40 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
52 private FCKeditor fckEditor;
53
54
55
56
57
58
59
60 public void setInstanceName(String instanceName) {
61 this.instanceName = instanceName;
62 }
63
64
65
66
67
68
69
70
71 public void setWidth(String width) {
72 this.width = width;
73 }
74
75
76
77
78
79
80
81 public void setHeight(String height) {
82 this.height = height;
83 }
84
85
86
87
88
89
90
91 public void setToolbarSet(String toolbarSet) {
92 this.toolbarSet = toolbarSet;
93 }
94
95
96
97
98
99
100
101 public void setValue(String value) {
102 this.value = value;
103 }
104
105
106
107
108
109
110
111 public void setBasePath(String basePath) {
112 this.basePath = basePath;
113 }
114
115 void setConfigParamAll(Map<String, String> map) {
116 fckEditor.getConfig().putAll(map);
117 }
118
119
120
121
122
123
124 public int doStartTag() throws JspException {
125
126 try {
127 fckEditor = new FCKeditor((HttpServletRequest) pageContext
128 .getRequest(), instanceName, width, height, toolbarSet,
129 value, basePath);
130 } catch (IllegalArgumentException e) {
131 throw new JspException(e);
132 }
133
134 return EVAL_BODY_INCLUDE;
135 }
136
137 @Override
138 public int doEndTag() throws JspException {
139
140 JspWriter out = pageContext.getOut();
141
142 try {
143 out.println(fckEditor);
144 } catch (IOException e) {
145 throw new JspException("Tag response could not be written to the user!",e);
146 }
147
148 return EVAL_PAGE;
149 }
150
151 }