KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ejtools > jmx > browser > web > taglib > NotificationCheckBoxTag


1 /*
2
3  * EJTools, the Enterprise Java Tools
4
5  *
6
7  * Distributable under LGPL license.
8
9  * See terms of license at www.gnu.org.
10
11  */

12
13 package org.ejtools.jmx.browser.web.taglib;
14
15
16
17 import javax.servlet.jsp.JspException JavaDoc;
18
19 import javax.servlet.jsp.tagext.TagSupport JavaDoc;
20
21
22
23 import org.apache.struts.util.RequestUtils;
24
25 import org.apache.struts.util.ResponseUtils;
26
27
28
29 /**
30
31  * Description of the Class
32
33  *
34
35  * @author letiemble
36
37  * @created 25 avril 2002
38
39  * @version $Revision: 1.6 $
40
41  * @todo Javadoc to complete
42
43  * @jsp:tag name="notificationCheckBox" body-content="empty"
44
45  */

46
47 public class NotificationCheckBoxTag extends TagSupport JavaDoc
48
49 {
50
51    /** Description of the Field */
52
53    protected String JavaDoc id = null;
54
55    /** Description of the Field */
56
57    protected String JavaDoc name = null;
58
59    /** Description of the Field */
60
61    protected String JavaDoc property = null;
62
63    /** Description of the Field */
64
65    protected String JavaDoc scope = null;
66
67
68
69
70
71    /**
72
73     * Description of the Method
74
75     *
76
77     * @return Description of the Returned Value
78
79     * @exception JspException Description of the Exception
80
81     */

82
83    public int doStartTag()
84
85       throws JspException JavaDoc
86
87    {
88
89       Object JavaDoc object = null;
90
91       Object JavaDoc objectId = null;
92
93
94
95       // Look up the requested bean (if necessary)
96

97       if (property != null)
98
99       {
100
101          object = RequestUtils.lookup(pageContext, name, property, scope);
102
103       }
104
105       else
106
107       {
108
109          object = RequestUtils.lookup(pageContext, name, scope);
110
111       }
112
113
114
115       if (object == null)
116
117       {
118
119          throw new JspException JavaDoc("Unable to find bean " + name + " or its property " + property);
120
121       }
122
123
124
125       objectId = RequestUtils.lookup(pageContext, id, scope);
126
127
128
129       if (objectId == null)
130
131       {
132
133          throw new JspException JavaDoc("Unable to find id");
134
135       }
136
137
138
139       StringBuffer JavaDoc output = new StringBuffer JavaDoc();
140
141
142
143       output.append("<input type=\"hidden\" name=\":mbean:");
144
145       output.append(ResponseUtils.filter(objectId.toString()));
146
147       output.append("\" value=\"");
148
149       output.append(ResponseUtils.filter(objectId.toString()));
150
151       output.append("\"/>");
152
153
154
155       output.append("<input type=\"checkbox\" name=\":state:");
156
157       output.append(ResponseUtils.filter(objectId.toString()));
158
159       output.append("\"");
160
161       if (Boolean.valueOf(object.toString()).booleanValue())
162
163       {
164
165          output.append(" checked");
166
167       }
168
169       output.append(" value=\"true\"/>");
170
171
172
173       ResponseUtils.write(pageContext, output.toString());
174
175
176
177       // Continue processing this page
178

179       return (SKIP_BODY);
180
181    }
182
183
184
185
186
187    /**
188
189     * @return The id value
190
191     * @jsp:attribute name="id" required="true" rtexprvalue="true"
192
193     */

194
195    public String JavaDoc getId()
196
197    {
198
199       return (this.id);
200
201    }
202
203
204
205
206
207    /**
208
209     * Getter for the name attribute
210
211     *
212
213     * @return The value of name attribute
214
215     * @jsp:attribute name="name" required="true" rtexprvalue="true"
216
217     */

218
219    public String JavaDoc getName()
220
221    {
222
223       return (this.name);
224
225    }
226
227
228
229
230
231    /**
232
233     * Gets the property attribute of the NotificationCheckBoxTag object
234
235     *
236
237     * @return The property value
238
239     * @jsp:attribute name="property" required="false" rtexprvalue="true"
240
241     */

242
243    public String JavaDoc getProperty()
244
245    {
246
247       return property;
248
249    }
250
251
252
253
254
255    /**
256
257     * Getter for the scope attribute
258
259     *
260
261     * @return The value of scope attribute
262
263     * @jsp:attribute name="scope" required="false" rtexprvalue="true"
264
265     */

266
267    public String JavaDoc getScope()
268
269    {
270
271       return (this.scope);
272
273    }
274
275
276
277
278
279    /** Release all allocated resources. */
280
281    public void release()
282
283    {
284
285       super.release();
286
287       name = null;
288
289       property = null;
290
291       scope = null;
292
293       id = null;
294
295    }
296
297
298
299
300
301    /**
302
303     * Sets the id attribute of the MBeanParameterEditorTag object
304
305     *
306
307     * @param id The new id value
308
309     */

310
311    public void setId(String JavaDoc id)
312
313    {
314
315       this.id = id;
316
317    }
318
319
320
321
322
323    /**
324
325     * Setter for the name attribute
326
327     *
328
329     * @param name The new name value
330
331     */

332
333    public void setName(String JavaDoc name)
334
335    {
336
337       this.name = name;
338
339    }
340
341
342
343
344
345    /**
346
347     * Sets the property attribute of the NotificationCheckBoxTag object
348
349     *
350
351     * @param property The new property value
352
353     */

354
355    public void setProperty(String JavaDoc property)
356
357    {
358
359       this.property = property;
360
361    }
362
363
364
365
366
367    /**
368
369     * Setter for the scope attribute
370
371     *
372
373     * @param scope The new scope value
374
375     */

376
377    public void setScope(String JavaDoc scope)
378
379    {
380
381       this.scope = scope;
382
383    }
384
385 }
386
387
Popular Tags