1 /* 2 * This file was automatically generated by Apache Tiles Autotag. 3 */ 4 package org.apache.tiles.jsp.taglib; 5 6 import java.io.IOException; 7 8 import javax.servlet.jsp.JspException; 9 import javax.servlet.jsp.tagext.SimpleTagSupport; 10 11 import org.apache.tiles.autotag.core.runtime.ModelBody; 12 import org.apache.tiles.autotag.core.runtime.AutotagRuntime; 13 14 /** 15 * <p> 16 * <strong>Inserts the value of an attribute into the page.</strong> 17 * </p> 18 * <p> 19 * This tag can be flexibly used to insert the value of an attribute into a 20 * page. As in other usages in Tiles, every attribute can be determined to have 21 * a "type", either set explicitly when it was defined, or "computed". If the 22 * type is not explicit, then if the attribute value is a valid definition, it 23 * will be inserted as such. Otherwise, if it begins with a "/" character, it 24 * will be treated as a "template". Finally, if it has not otherwise been 25 * assigned a type, it will be treated as a String and included without any 26 * special handling. 27 * </p> 28 * 29 * <p> 30 * <strong>Example : </strong> 31 * </p> 32 * 33 * <pre> 34 * <code> 35 * <tiles:insertAttribute name="body" /> 36 * </code> 37 * </pre> 38 */ 39 public class InsertAttributeTag extends SimpleTagSupport { 40 41 /** 42 * The template model. 43 */ 44 private org.apache.tiles.template.InsertAttributeModel model = new org.apache.tiles.template.InsertAttributeModel(); 45 46 /** 47 * If <code>true</code>, if an exception happens during 48 * rendering, of if the attribute is null, the problem will be ignored. 49 */ 50 private boolean ignore; 51 52 /** 53 * The preparer to invoke before rendering the attribute. 54 */ 55 private java.lang.String preparer; 56 57 /** 58 * A comma-separated list of roles. If present, the attribute 59 * will be rendered only if the current user belongs to one of the roles. 60 */ 61 private java.lang.String role; 62 63 /** 64 * The default value of the attribute. To use only if 65 * the attribute was not computed. 66 */ 67 private java.lang.Object defaultValue; 68 69 /** 70 * The default comma-separated list of roles. To use 71 * only if the attribute was not computed. 72 */ 73 private java.lang.String defaultValueRole; 74 75 /** 76 * The default type of the attribute. To use only if 77 * the attribute was not computed. 78 */ 79 private java.lang.String defaultValueType; 80 81 /** 82 * The name of the attribute. 83 */ 84 private java.lang.String name; 85 86 /** 87 * The attribute to use immediately, if not null. 88 */ 89 private org.apache.tiles.Attribute value; 90 91 /** 92 * If <code>true</code>, the response will be flushed after the insert. 93 */ 94 private boolean flush; 95 96 /** 97 * Getter for ignore property. 98 * 99 * @return 100 * If <code>true</code>, if an exception happens during 101 * rendering, of if the attribute is null, the problem will be ignored. 102 */ 103 public boolean isIgnore() { 104 return ignore; 105 } 106 107 /** 108 * Setter for ignore property. 109 * 110 * @param ignore 111 * If <code>true</code>, if an exception happens during 112 * rendering, of if the attribute is null, the problem will be ignored. 113 */ 114 public void setIgnore(boolean ignore) { 115 this.ignore = ignore; 116 } 117 118 /** 119 * Getter for preparer property. 120 * 121 * @return 122 * The preparer to invoke before rendering the attribute. 123 */ 124 public java.lang.String getPreparer() { 125 return preparer; 126 } 127 128 /** 129 * Setter for preparer property. 130 * 131 * @param preparer 132 * The preparer to invoke before rendering the attribute. 133 */ 134 public void setPreparer(java.lang.String preparer) { 135 this.preparer = preparer; 136 } 137 138 /** 139 * Getter for role property. 140 * 141 * @return 142 * A comma-separated list of roles. If present, the attribute 143 * will be rendered only if the current user belongs to one of the roles. 144 */ 145 public java.lang.String getRole() { 146 return role; 147 } 148 149 /** 150 * Setter for role property. 151 * 152 * @param role 153 * A comma-separated list of roles. If present, the attribute 154 * will be rendered only if the current user belongs to one of the roles. 155 */ 156 public void setRole(java.lang.String role) { 157 this.role = role; 158 } 159 160 /** 161 * Getter for defaultValue property. 162 * 163 * @return 164 * The default value of the attribute. To use only if 165 * the attribute was not computed. 166 */ 167 public java.lang.Object getDefaultValue() { 168 return defaultValue; 169 } 170 171 /** 172 * Setter for defaultValue property. 173 * 174 * @param defaultValue 175 * The default value of the attribute. To use only if 176 * the attribute was not computed. 177 */ 178 public void setDefaultValue(java.lang.Object defaultValue) { 179 this.defaultValue = defaultValue; 180 } 181 182 /** 183 * Getter for defaultValueRole property. 184 * 185 * @return 186 * The default comma-separated list of roles. To use 187 * only if the attribute was not computed. 188 */ 189 public java.lang.String getDefaultValueRole() { 190 return defaultValueRole; 191 } 192 193 /** 194 * Setter for defaultValueRole property. 195 * 196 * @param defaultValueRole 197 * The default comma-separated list of roles. To use 198 * only if the attribute was not computed. 199 */ 200 public void setDefaultValueRole(java.lang.String defaultValueRole) { 201 this.defaultValueRole = defaultValueRole; 202 } 203 204 /** 205 * Getter for defaultValueType property. 206 * 207 * @return 208 * The default type of the attribute. To use only if 209 * the attribute was not computed. 210 */ 211 public java.lang.String getDefaultValueType() { 212 return defaultValueType; 213 } 214 215 /** 216 * Setter for defaultValueType property. 217 * 218 * @param defaultValueType 219 * The default type of the attribute. To use only if 220 * the attribute was not computed. 221 */ 222 public void setDefaultValueType(java.lang.String defaultValueType) { 223 this.defaultValueType = defaultValueType; 224 } 225 226 /** 227 * Getter for name property. 228 * 229 * @return 230 * The name of the attribute. 231 */ 232 public java.lang.String getName() { 233 return name; 234 } 235 236 /** 237 * Setter for name property. 238 * 239 * @param name 240 * The name of the attribute. 241 */ 242 public void setName(java.lang.String name) { 243 this.name = name; 244 } 245 246 /** 247 * Getter for value property. 248 * 249 * @return 250 * The attribute to use immediately, if not null. 251 */ 252 public org.apache.tiles.Attribute getValue() { 253 return value; 254 } 255 256 /** 257 * Setter for value property. 258 * 259 * @param value 260 * The attribute to use immediately, if not null. 261 */ 262 public void setValue(org.apache.tiles.Attribute value) { 263 this.value = value; 264 } 265 266 /** 267 * Getter for flush property. 268 * 269 * @return 270 * If <code>true</code>, the response will be flushed after the insert. 271 */ 272 public boolean isFlush() { 273 return flush; 274 } 275 276 /** 277 * Setter for flush property. 278 * 279 * @param flush 280 * If <code>true</code>, the response will be flushed after the insert. 281 */ 282 public void setFlush(boolean flush) { 283 this.flush = flush; 284 } 285 286 /** {@inheritDoc} */ 287 @Override 288 public void doTag() throws JspException, IOException { 289 AutotagRuntime<org.apache.tiles.request.Request> runtime = new org.apache.tiles.request.jsp.autotag.JspAutotagRuntime(); 290 if (runtime instanceof SimpleTagSupport) { 291 SimpleTagSupport tag = (SimpleTagSupport) runtime; 292 tag.setJspContext(getJspContext()); 293 tag.setJspBody(getJspBody()); 294 tag.setParent(getParent()); 295 tag.doTag(); 296 } 297 org.apache.tiles.request.Request request = runtime.createRequest(); 298 ModelBody modelBody = runtime.createModelBody(); 299 model.execute( 300 ignore, 301 preparer, 302 role, 303 defaultValue, 304 defaultValueRole, 305 defaultValueType, 306 name, 307 value, 308 flush, 309 request, modelBody 310 ); 311 } 312 }