KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > opensymphony > webwork > views > jsp > ParameterizedTagSupport


1 /*
2  * Copyright (c) 2002-2003 by OpenSymphony
3  * All rights reserved.
4  */

5 package com.opensymphony.webwork.views.jsp;
6
7 import org.apache.commons.logging.Log;
8 import org.apache.commons.logging.LogFactory;
9
10 import java.util.HashMap JavaDoc;
11 import java.util.Map JavaDoc;
12
13
14 /**
15  * Created by IntelliJ IDEA.
16  * User: jcarreira
17  * Date: Oct 16, 2003
18  * Time: 11:00:38 PM
19  * To change this template use Options | File Templates.
20  */

21 public abstract class ParameterizedTagSupport extends WebWorkTagSupport implements ParamTag.Parametric {
22     //~ Static fields/initializers /////////////////////////////////////////////
23

24     final protected static Log log = LogFactory.getLog(ParameterizedTagSupport.class);
25
26     //~ Instance fields ////////////////////////////////////////////////////////
27

28     Map JavaDoc params;
29
30     //~ Methods ////////////////////////////////////////////////////////////////
31

32     public Map JavaDoc getParameters() {
33         if (params == null) {
34             params = new HashMap JavaDoc();
35         }
36
37         return params;
38     }
39
40     public void addParameter(String JavaDoc key, Object JavaDoc value) {
41         if (key != null) {
42             Map JavaDoc myParams = getParameters();
43
44             if (value == null) {
45                 myParams.remove(key);
46             } else {
47                 params.put(key, value);
48             }
49         }
50     }
51
52     /**
53      * Resets the attributes of this tag so that the tag may be reused. As a general rule, only properties that are
54      * not specified as an attribute or properties that are derived need to be reset. Examples of this would include
55      * the parameters Map in ParameterizedTag and the namespace in the ActionTag (which can be a derived value).
56      * <p />
57      * This should be the last thing called as part of the doEndTag
58      */

59     protected void reset() {
60         this.getParameters().clear();
61     }
62 }
63
Popular Tags