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   * ConfigTag.java - TODO DOCUMENTME!
33   *
34   * @version $Id: ConfigTag.java 2007 2008-05-19 17:53:34Z th-schwarz $
35   */
36  public class ConfigTag extends TagSupport implements DynamicAttributes {
37  
38  	private Map<String, String> params = new HashMap<String, String>();
39  	
40  	private static final long serialVersionUID = -5282810094404700422L;
41  
42  	@Override
43  	public int doStartTag() throws JspException {
44  
45  		Tag ancestor = findAncestorWithClass(this, EditorTag.class);
46  		if (ancestor == null)
47  			throw new JspException(
48  					"the config tag can only be nested within an editor tag");
49  		EditorTag editorTag = (EditorTag) ancestor;
50  		editorTag.setConfigParamAll(params);
51  		
52  		return SKIP_BODY;
53  	}
54  
55  	public void setDynamicAttribute(String arg0, String arg1, Object arg2)
56  			throws JspException {
57  		if (arg2 != null)
58  			params.put(arg1, arg2.toString());
59  	}
60  
61  }