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>Inserts the value of an attribute into the page.</strong>
21   * </p>
22   * <p>
23   * This tag can be flexibly used to insert the value of an attribute into a
24   * page. As in other usages in Tiles, every attribute can be determined to have
25   * a "type", either set explicitly when it was defined, or "computed". If the
26   * type is not explicit, then if the attribute value is a valid definition, it
27   * will be inserted as such. Otherwise, if it begins with a "/" character, it
28   * will be treated as a "template". Finally, if it has not otherwise been
29   * assigned a type, it will be treated as a String and included without any
30   * special handling.
31   * </p>
32   * 
33   * <p>
34   * <strong>Example : </strong>
35   * </p>
36   * 
37   * <pre>
38   * &lt;code&gt;
39   *           &lt;tiles:insertAttribute name=&quot;body&quot; /&gt;
40   *         &lt;/code&gt;
41   * </pre>
42   */
43  public class InsertAttributeFMModel implements TemplateDirectiveModel {
44  
45      /**
46       * The template model.
47       */
48      private org.apache.tiles.template.InsertAttributeModel model;
49  
50      /**
51       * Constructor.
52       *
53       * @param model
54       *            The template model.
55       */
56      public InsertAttributeFMModel(org.apache.tiles.template.InsertAttributeModel model) {
57          this.model = model;
58      }
59  
60      /** {@inheritDoc} */
61      @SuppressWarnings("unchecked")
62      @Override
63      public void execute(Environment env, @SuppressWarnings("rawtypes") Map params, TemplateModel[] loopVars,
64              TemplateDirectiveBody body) throws TemplateException, IOException {
65          AutotagRuntime<org.apache.tiles.request.Request> runtime = new org.apache.tiles.request.freemarker.autotag.FreemarkerAutotagRuntime();
66          if (runtime instanceof TemplateDirectiveModel) {
67              ((TemplateDirectiveModel) runtime).execute(env, params, loopVars, body);
68          }
69          org.apache.tiles.request.Request request = runtime.createRequest();
70          ModelBody modelBody = runtime.createModelBody();
71          model.execute(
72              runtime.getParameter("ignore", java.lang.Boolean.class, false),
73              runtime.getParameter("preparer", java.lang.String.class, null),
74              runtime.getParameter("role", java.lang.String.class, null),
75              runtime.getParameter("defaultValue", java.lang.Object.class, null),
76              runtime.getParameter("defaultValueRole", java.lang.String.class, null),
77              runtime.getParameter("defaultValueType", java.lang.String.class, null),
78              runtime.getParameter("name", java.lang.String.class, null),
79              runtime.getParameter("value", org.apache.tiles.Attribute.class, null),
80              runtime.getParameter("flush", java.lang.Boolean.class, false),
81                  request, modelBody
82          );
83      }
84  }