1 7 package org.ejtools.servlet.http.jsp.tagext; 8 9 import javax.servlet.jsp.JspException ; 10 import javax.servlet.jsp.tagext.TagSupport ; 11 12 import org.apache.struts.util.RequestUtils; 13 import org.apache.struts.util.ResponseUtils; 14 15 30 public class CheckBoxObjectTag extends TagSupport 31 { 32 33 protected String id = null; 34 35 protected String name = null; 36 37 protected String property = null; 38 39 protected String scope = null; 40 41 protected String value = "true"; 42 43 44 50 public int doStartTag() 51 throws JspException 52 { 53 Object object = null; 54 55 if (property != null) 57 { 58 object = RequestUtils.lookup(pageContext, this.name, this.property, this.scope); 59 } 60 else 61 { 62 object = RequestUtils.lookup(pageContext, this.name, this.scope); 63 } 64 65 if (object == null) 66 { 67 throw new JspException ("Unable to find bean " + this.name + " or its property " + this.property); 68 } 69 70 StringBuffer output = new StringBuffer (); 72 output.append("<input type=\"checkbox\" name=\""); 73 output.append(this.id); 74 output.append("\""); 75 if (Boolean.valueOf(object.toString()).booleanValue()) 76 { 77 output.append(" checked"); 78 } 79 output.append(" value=\""); 80 output.append(ResponseUtils.filter(this.value.toString())); 81 output.append("\"/>"); 82 83 ResponseUtils.write(pageContext, output.toString()); 84 85 return (SKIP_BODY); 87 } 88 89 90 98 public String getId() 99 { 100 return this.id; 101 } 102 103 104 112 public String getName() 113 { 114 return this.name; 115 } 116 117 118 126 public String getProperty() 127 { 128 return this.property; 129 } 130 131 132 140 public String getScope() 141 { 142 return this.scope; 143 } 144 145 146 154 public String getValue() 155 { 156 return this.value; 157 } 158 159 160 161 public void release() 162 { 163 super.release(); 164 this.id = null; 165 this.name = null; 166 this.property = null; 167 this.scope = null; 168 this.value = "true"; 169 } 170 171 172 177 public void setId(String id) 178 { 179 this.id = id; 180 } 181 182 183 188 public void setName(String name) 189 { 190 this.name = name; 191 } 192 193 194 199 public void setProperty(String property) 200 { 201 this.property = property; 202 } 203 204 205 210 public void setScope(String scope) 211 { 212 this.scope = scope; 213 } 214 215 216 221 public void setValue(String value) 222 { 223 this.value = value; 224 } 225 } 226 227 | Popular Tags |