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   * Selects a container to be used as the "current" container.
19   */
20  public class SetCurrentContainerFMModel implements TemplateDirectiveModel {
21  
22      /**
23       * The template model.
24       */
25      private org.apache.tiles.template.SetCurrentContainerModel model;
26  
27      /**
28       * Constructor.
29       *
30       * @param model
31       *            The template model.
32       */
33      public SetCurrentContainerFMModel(org.apache.tiles.template.SetCurrentContainerModel model) {
34          this.model = model;
35      }
36  
37      /** {@inheritDoc} */
38      @SuppressWarnings("unchecked")
39      @Override
40      public void execute(Environment env, @SuppressWarnings("rawtypes") Map params, TemplateModel[] loopVars,
41              TemplateDirectiveBody body) throws TemplateException, IOException {
42          AutotagRuntime<org.apache.tiles.request.Request> runtime = new org.apache.tiles.request.freemarker.autotag.FreemarkerAutotagRuntime();
43          if (runtime instanceof TemplateDirectiveModel) {
44              ((TemplateDirectiveModel) runtime).execute(env, params, loopVars, body);
45          }
46          org.apache.tiles.request.Request request = runtime.createRequest();
47          model.execute(
48              runtime.getParameter("containerKey", java.lang.String.class, null),
49                  request
50          );
51      }
52  }