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>Add an element to the surrounding list. Equivalent to 'putAttribute',
18   * but for list element.</strong>
19   * </p>
20   * 
21   * <p>
22   * Add an element to the surrounding list. This tag can only be used inside
23   * 'putListAttribute' or 'addListAttribute' tags. Value can come from a direct
24   * assignment (value="aValue")
25   * </p>
26   */
27  public class AddAttributeDirective extends Directive {
28  
29      /**
30       * The template model.
31       */
32      private org.apache.tiles.template.AddAttributeModel model = new org.apache.tiles.template.AddAttributeModel();
33  
34      /** {@inheritDoc} */
35      @Override
36      public String getName() {
37          return "tiles_addAttribute";
38      }
39  
40      /** {@inheritDoc} */
41      @Override
42      public int getType() {
43          return BLOCK;
44      }
45  
46      /** {@inheritDoc} */
47      @Override
48      public boolean render(InternalContextAdapter context, Writer writer, Node node)
49              throws IOException {
50          AutotagRuntime<org.apache.tiles.request.Request> runtime = new org.apache.tiles.request.velocity.autotag.VelocityAutotagRuntime();
51          if (runtime instanceof Directive) {
52              ((Directive) runtime).render(context, writer, node);
53          }
54          org.apache.tiles.request.Request request = runtime.createRequest();
55          ModelBody modelBody = runtime.createModelBody();
56          model.execute(
57              runtime.getParameter("value", java.lang.Object.class, null),
58              runtime.getParameter("expression", java.lang.String.class, null),
59              runtime.getParameter("role", java.lang.String.class, null),
60              runtime.getParameter("type", java.lang.String.class, null),
61              request, modelBody
62          );
63          return true;
64      }
65  }