View Javadoc

1   /*
2    * This file was automatically generated by Apache Tiles Autotag.
3    */
4   package org.apache.tiles.velocity.template;
5   
6   import java.io.IOException;
7   import java.io.Writer;
8   
9   import org.apache.tiles.autotag.core.runtime.ModelBody;
10  import org.apache.tiles.autotag.core.runtime.AutotagRuntime;
11  import org.apache.velocity.context.InternalContextAdapter;
12  import org.apache.velocity.runtime.directive.Directive;
13  import org.apache.velocity.runtime.parser.node.Node;
14  
15  /**
16   * <p>
17   * <strong>Declare a list that will be pass as an attribute. </strong>
18   * </p>
19   * <p>
20   * Declare a list that will be pass as an attribute . List elements are added
21   * using the tag 'addAttribute' or 'addListAttribute'. This tag can only be used
22   * inside 'insertTemplate', 'insertDefinition' or 'definition' tag.
23   * </p>
24   */
25  public class AddListAttributeDirective extends Directive {
26  
27      /**
28       * The template model.
29       */
30      private org.apache.tiles.template.AddListAttributeModel model = new org.apache.tiles.template.AddListAttributeModel();
31  
32      /** {@inheritDoc} */
33      @Override
34      public String getName() {
35          return "tiles_addListAttribute";
36      }
37  
38      /** {@inheritDoc} */
39      @Override
40      public int getType() {
41          return BLOCK;
42      }
43  
44      /** {@inheritDoc} */
45      @Override
46      public boolean render(InternalContextAdapter context, Writer writer, Node node)
47              throws IOException {
48          AutotagRuntime<org.apache.tiles.request.Request> runtime = new org.apache.tiles.request.velocity.autotag.VelocityAutotagRuntime();
49          if (runtime instanceof Directive) {
50              ((Directive) runtime).render(context, writer, node);
51          }
52          org.apache.tiles.request.Request request = runtime.createRequest();
53          ModelBody modelBody = runtime.createModelBody();
54          model.execute(
55              runtime.getParameter("role", java.lang.String.class, null),
56              request, modelBody
57          );
58          return true;
59      }
60  }