1/*2 * This file was automatically generated by Apache Tiles Autotag.3 */4package org.apache.tiles.velocity.template;
56import java.io.IOException;
7import java.io.Writer;
89import org.apache.tiles.autotag.core.runtime.ModelBody;
10import org.apache.tiles.autotag.core.runtime.AutotagRuntime;
11import org.apache.velocity.context.InternalContextAdapter;
12import org.apache.velocity.runtime.directive.Directive;
13import org.apache.velocity.runtime.parser.node.Node;
1415/**16 * <p>17 * <strong>Put an attribute in enclosing attribute container tag.</strong>18 * </p>19 * <p>20 * Enclosing attribute container tag can be :21 * <ul>22 * <li><initContainer></li>23 * <li><definition></li>24 * <li><insertAttribute></li>25 * <li><insertDefinition></li>26 * <li><putListAttribute></li>27 * </ul>28 * (or any other tag which implements the <code>PutAttributeTagParent</code>29 * interface. Exception is thrown if no appropriate tag can be found.30 * </p>31 * <p>32 * Put tag can have following atributes :33 * <ul>34 * <li>name : Name of the attribute</li>35 * <li>value : value to put as attribute</li>36 * <li>type : value type. Possible type are : string (value is used as direct37 * string), template (value is used as a page url to insert), definition (value38 * is used as a definition name to insert), object (value is used as it is)</li>39 * <li>role : Role to check when 'insertAttribute' will be called.</li>40 * </ul>41 * </p>42 * <p>43 * Value can also come from tag body. Tag body is taken into account only if44 * value is not set by one of the tag attributes. In this case Attribute type is45 * "string", unless tag body define another type.46 * </p>47 */48publicclassPutAttributeDirectiveextends Directive {
4950/**51 * The template model.52 */53private org.apache.tiles.template.PutAttributeModel model = new org.apache.tiles.template.PutAttributeModel();
5455/** {@inheritDoc} */56 @Override
57public String getName() {
58return"tiles_putAttribute";
59 }
6061/** {@inheritDoc} */62 @Override
63publicint getType() {
64return BLOCK;
65 }
6667/** {@inheritDoc} */68 @Override
69publicboolean render(InternalContextAdapter context, Writer writer, Node node)
70throws IOException {
71 AutotagRuntime<org.apache.tiles.request.Request> runtime = new org.apache.tiles.request.velocity.autotag.VelocityAutotagRuntime();
72if (runtime instanceof Directive) {
73 ((Directive) runtime).render(context, writer, node);
74 }
75 org.apache.tiles.request.Request request = runtime.createRequest();
76 ModelBody modelBody = runtime.createModelBody();
77 model.execute(
78 runtime.getParameter("name", java.lang.String.class, null),
79 runtime.getParameter("value", java.lang.Object.class, null),
80 runtime.getParameter("expression", java.lang.String.class, null),
81 runtime.getParameter("role", java.lang.String.class, null),
82 runtime.getParameter("type", java.lang.String.class, null),
83 runtime.getParameter("cascade", java.lang.Boolean.class, false),
84 request, modelBody
85 );
86returntrue;
87 }
88 }