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.AutotagRuntime;
10  
11  import freemarker.core.Environment;
12  import freemarker.template.TemplateDirectiveBody;
13  import freemarker.template.TemplateDirectiveModel;
14  import freemarker.template.TemplateException;
15  import freemarker.template.TemplateModel;
16  
17  /**
18   * <p>
19   * <strong>Import attribute(s) in specified context.</strong>
20   * </p>
21   * <p>
22   * Import attribute(s) to requested scope. Attribute name and scope are
23   * optional. If not specified, all attributes are imported in page scope. Once
24   * imported, an attribute can be used as any other beans from jsp contexts.
25   * </p>
26   */
27  public class ImportAttributeFMModel implements TemplateDirectiveModel {
28  
29      /**
30       * The template model.
31       */
32      private org.apache.tiles.template.ImportAttributeModel model;
33  
34      /**
35       * Constructor.
36       *
37       * @param model
38       *            The template model.
39       */
40      public ImportAttributeFMModel(org.apache.tiles.template.ImportAttributeModel model) {
41          this.model = model;
42      }
43  
44      /** {@inheritDoc} */
45      @SuppressWarnings("unchecked")
46      @Override
47      public void execute(Environment env, @SuppressWarnings("rawtypes") Map params, TemplateModel[] loopVars,
48              TemplateDirectiveBody body) throws TemplateException, IOException {
49          AutotagRuntime<org.apache.tiles.request.Request> runtime = new org.apache.tiles.request.freemarker.autotag.FreemarkerAutotagRuntime();
50          if (runtime instanceof TemplateDirectiveModel) {
51              ((TemplateDirectiveModel) runtime).execute(env, params, loopVars, body);
52          }
53          org.apache.tiles.request.Request request = runtime.createRequest();
54          model.execute(
55              runtime.getParameter("name", java.lang.String.class, null),
56              runtime.getParameter("scope", java.lang.String.class, null),
57              runtime.getParameter("toName", java.lang.String.class, null),
58              runtime.getParameter("ignore", java.lang.Boolean.class, false),
59                  request
60          );
61      }
62  }