View Javadoc

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  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  /**
32   * This tag sets configuration options for the surrounding editor tag. Provide
33   * any configuraion options you want as described <a
34   * href="http://docs.fckeditor.net/FCKeditor_2.x/Developers_Guide/Configuration/Configuration_Options">here</a>.
35   * This tag utilizes the dynamic attribute features provided by the
36   * {@link DynamicAttributes} interface.<br />
37   * <strong>Attention</strong>: This tag can only be nested with an editor tag.
38   * 
39   * @version $Id: ConfigTag.java 2151 2008-07-02 22:03:15Z mosipov $
40   */
41  public class ConfigTag extends TagSupport implements DynamicAttributes {
42  
43  	private Map<String, String> params = new HashMap<String, String>();
44  
45  	private static final long serialVersionUID = -5282810094404700422L;
46  
47  	@Override
48  	public int doStartTag() throws JspException {
49  
50  		Tag ancestor = findAncestorWithClass(this, EditorTag.class);
51  		if (ancestor == null)
52  			throw new JspException(
53  					"the config tag can only be nested within an editor tag");
54  		EditorTag editorTag = (EditorTag) ancestor;
55  		editorTag.setConfigParamAll(params);
56  
57  		return SKIP_BODY;
58  	}
59  
60  	/**
61  	 * Sets the desired FCKeditor configuration option.
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  }