1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59 package com.ivata.mask.web.tag.util;
60
61 import java.util.HashMap;
62
63 import javax.servlet.jsp.JspException;
64 import javax.servlet.jsp.tagext.BodyTagSupport;
65
66
67 /***
68 * <p>This tag defines a <code>Map</code> in page scope and assigns
69 * the entries to it defined by <code>MapEntryTag</code> instance
70 * within
71 * the tag body.</p>
72 *
73 * <p><b>Tag attributes:</b><br/>
74 * <table cellpadding='2' cellspacing='5' border='0' align='center'
75 * width='85%'>
76 * <tr class='TableHeadingColor'>
77 * <th>attribute</th>
78 * <th>reqd.</th>
79 * <th>param. class</th>
80 * <th width='100%'>description</th>
81 * </tr>
82 * <tr class='TableRowColor'>
83 * <td>id</td>
84 * <td>true</td>
85 * <td><code>String</code></td>
86 * <td>Specifies the name of the scripting variable and associated
87 * page scope attribute which will be made available.</td>
88 * </tr>
89 * </table>
90 * </p>
91 * @since ivata masks 0.5 (2002-01-23)
92 * @author Colin MacLeod
93 * <a href='mailto:colin.macleod@ivata.com'>colin.macleod@ivata.com</a>
94 * @version $Revision: 1.2 $
95 */
96 public class MapTag extends BodyTagSupport {
97 /***
98 * <p>Specifies the name of the scripting variable and associated page
99 * scope attribute which will be made available.</p>
100 */
101 private String id;
102 /***
103 * <p>This internal implementaion actually does all the work :-).</p>
104 */
105 private HashMap map = new HashMap();
106
107 /***
108 * <p>This method is called when the JSP engine encounters the start
109 * tag, after the attributes are processed.<p>
110 *
111 * <p>Scripting variables (if any) have their values set here.</p>
112 *
113 * @return <code>EVAL_BODY_BUFFERED</code> since we always want to
114 * evaluate the tag body once.
115 * @throws JspException if there is a <code>NamingExcpetion</code>
116 * getting the <code>InitialContext</code>
117 * @throws JspException encapsulates any exception when calling
118 * <code>out.println</code>
119 */
120 public int doStartTag() throws JspException {
121 setMap(map);
122 return EVAL_BODY_BUFFERED;
123 }
124
125 /***
126 * <p>Specifies the name of the scripting variable and associated page
127 * scope attribute which will be made available.</p>
128 *
129 * @return the current value of id.
130 */
131 public final String getId() {
132 return id;
133 }
134
135 /***
136 * <p>Specifies the name of the scripting variable and associated page
137 * scope attribute which will be made available.</p>
138 *
139 * @param idParam the new value of id.
140 */
141 public final void setId(final String idParam) {
142 this.id = idParam;
143 }
144
145 /***
146 * <p>This internal implementaion actually does all the work :-).</p>
147 *
148 * @return the current value of map.
149 */
150 public final HashMap getMap() {
151 return map;
152 }
153
154 /***
155 * <p>This internal implementaion actually does all the work :-).</p>
156 *
157 * @param mapParam the new value of map.
158 */
159 public final void setMap(final HashMap mapParam) {
160 this.map = mapParam;
161 pageContext.setAttribute(id, mapParam);
162 }
163 }