1 12 13 package org.ejtools.jmx.browser.web.taglib; 14 15 16 17 import javax.servlet.jsp.JspException ; 18 19 import javax.servlet.jsp.tagext.TagSupport ; 20 21 22 23 import org.apache.struts.util.RequestUtils; 24 25 import org.apache.struts.util.ResponseUtils; 26 27 28 29 46 47 public class NotificationCheckBoxTag extends TagSupport 48 49 { 50 51 52 53 protected String id = null; 54 55 56 57 protected String name = null; 58 59 60 61 protected String property = null; 62 63 64 65 protected String scope = null; 66 67 68 69 70 71 82 83 public int doStartTag() 84 85 throws JspException 86 87 { 88 89 Object object = null; 90 91 Object objectId = null; 92 93 94 95 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 ("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 ("Unable to find id"); 134 135 } 136 137 138 139 StringBuffer output = new StringBuffer (); 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 179 return (SKIP_BODY); 180 181 } 182 183 184 185 186 187 194 195 public String getId() 196 197 { 198 199 return (this.id); 200 201 } 202 203 204 205 206 207 218 219 public String getName() 220 221 { 222 223 return (this.name); 224 225 } 226 227 228 229 230 231 242 243 public String getProperty() 244 245 { 246 247 return property; 248 249 } 250 251 252 253 254 255 266 267 public String getScope() 268 269 { 270 271 return (this.scope); 272 273 } 274 275 276 277 278 279 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 310 311 public void setId(String id) 312 313 { 314 315 this.id = id; 316 317 } 318 319 320 321 322 323 332 333 public void setName(String name) 334 335 { 336 337 this.name = name; 338 339 } 340 341 342 343 344 345 354 355 public void setProperty(String property) 356 357 { 358 359 this.property = property; 360 361 } 362 363 364 365 366 367 376 377 public void setScope(String scope) 378 379 { 380 381 this.scope = scope; 382 383 } 384 385 } 386 387 | Popular Tags |