View Javadoc

1   /*
2    * This file was automatically generated by Apache Tiles Autotag.
3    */
4   package org.apache.tiles.freemarker.template;
5   
6   import java.io.IOException;
7   import java.util.Map;
8   
9   import org.apache.tiles.autotag.core.runtime.ModelBody;
10  import org.apache.tiles.autotag.core.runtime.AutotagRuntime;
11  
12  import freemarker.core.Environment;
13  import freemarker.template.TemplateDirectiveBody;
14  import freemarker.template.TemplateDirectiveModel;
15  import freemarker.template.TemplateException;
16  import freemarker.template.TemplateModel;
17  
18  /**
19   * <p>
20   * <strong>Declare a list that will be pass as an attribute. </strong>
21   * </p>
22   * <p>
23   * Declare a list that will be pass as an attribute . List elements are added
24   * using the tag 'addAttribute' or 'addListAttribute'. This tag can only be used
25   * inside 'insertTemplate', 'insertDefinition' or 'definition' tag.
26   * </p>
27   */
28  public class AddListAttributeFMModel implements TemplateDirectiveModel {
29  
30      /**
31       * The template model.
32       */
33      private org.apache.tiles.template.AddListAttributeModel model;
34  
35      /**
36       * Constructor.
37       *
38       * @param model
39       *            The template model.
40       */
41      public AddListAttributeFMModel(org.apache.tiles.template.AddListAttributeModel model) {
42          this.model = model;
43      }
44  
45      /** {@inheritDoc} */
46      @SuppressWarnings("unchecked")
47      @Override
48      public void execute(Environment env, @SuppressWarnings("rawtypes") Map params, TemplateModel[] loopVars,
49              TemplateDirectiveBody body) throws TemplateException, IOException {
50          AutotagRuntime<org.apache.tiles.request.Request> runtime = new org.apache.tiles.request.freemarker.autotag.FreemarkerAutotagRuntime();
51          if (runtime instanceof TemplateDirectiveModel) {
52              ((TemplateDirectiveModel) runtime).execute(env, params, loopVars, body);
53          }
54          org.apache.tiles.request.Request request = runtime.createRequest();
55          ModelBody modelBody = runtime.createModelBody();
56          model.execute(
57              runtime.getParameter("role", java.lang.String.class, null),
58                  request, modelBody
59          );
60      }
61  }