1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 package net.fckeditor.tags;
22
23 import java.util.HashMap;
24 import java.util.Map;
25
26 import javax.servlet.jsp.JspException;
27 import javax.servlet.jsp.tagext.DynamicAttributes;
28 import javax.servlet.jsp.tagext.Tag;
29 import javax.servlet.jsp.tagext.TagSupport;
30
31 import net.fckeditor.FCKeditorConfig;
32
33
34
35
36
37
38
39 public class ConfigTag extends TagSupport implements DynamicAttributes {
40
41 private Map<String, String> params = new HashMap<String, String>();
42
43 private static final long serialVersionUID = -5282810094404700422L;
44
45 @Override
46 public int doStartTag() throws JspException {
47
48 Tag ancestor = findAncestorWithClass(this, EditorTag.class);
49 if (ancestor == null)
50 throw new JspException(
51 "the config tag can only be nested within an editor tag");
52 EditorTag editorTag = (EditorTag) ancestor;
53
54 for (Map.Entry<String, String> option : params.entrySet())
55 editorTag.setConfig(option.getKey(), option.getValue());
56
57 return SKIP_BODY;
58 }
59
60
61
62
63 public void setDynamicAttribute(String arg0, String name, Object value)
64 throws JspException {
65 if (value != null)
66 params.put(name, value.toString());
67 }
68
69 }