Coverage Report - org.apache.tiles.freemarker.template.InsertDefinitionFMModel
 
Classes in this File Line Coverage Branch Coverage Complexity
InsertDefinitionFMModel
30%
3/10
0%
0/2
1.5
 
 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>Insert a definition.</strong>
 21  
  * </p>
 22  
  * <p>
 23  
  * Insert a definition with the possibility to override and specify parameters
 24  
  * (called attributes). A definition can be seen as a (partially or totally)
 25  
  * filled template that can override or complete attribute values.
 26  
  * <code>&lt;tiles:insertDefinition&gt;</code> allows to define these attributes
 27  
  * and pass them to the inserted jsp page, called template. Attributes are
 28  
  * defined using nested tag <code>&lt;tiles:putAttribute&gt;</code> or
 29  
  * <code>&lt;tiles:putListAttribute&gt;</code>.
 30  
  * </p>
 31  
  * <p>
 32  
  * You must specify <code>name</code> tag attribute, for inserting a definition
 33  
  * from definitions factory.
 34  
  * </p>
 35  
  * <p>
 36  
  * <strong>Example : </strong>
 37  
  * </p>
 38  
  * 
 39  
  * <pre>
 40  
  * &lt;code&gt;
 41  
  *           &lt;tiles:insertDefinition name=&quot;.my.tiles.defininition flush=&quot;true&quot;&gt;
 42  
  *              &lt;tiles:putAttribute name=&quot;title&quot; value=&quot;My first page&quot; /&gt;
 43  
  *              &lt;tiles:putAttribute name=&quot;header&quot; value=&quot;/common/header.jsp&quot; /&gt;
 44  
  *              &lt;tiles:putAttribute name=&quot;footer&quot; value=&quot;/common/footer.jsp&quot; /&gt;
 45  
  *              &lt;tiles:putAttribute name=&quot;menu&quot; value=&quot;/basic/menu.jsp&quot; /&gt;
 46  
  *              &lt;tiles:putAttribute name=&quot;body&quot; value=&quot;/basic/helloBody.jsp&quot; /&gt;
 47  
  *           &lt;/tiles:insertDefinition&gt;
 48  
  *         &lt;/code&gt;
 49  
  * </pre>
 50  
  */
 51  
 public class InsertDefinitionFMModel implements TemplateDirectiveModel {
 52  
 
 53  
     /**
 54  
      * The template model.
 55  
      */
 56  
     private org.apache.tiles.template.InsertDefinitionModel model;
 57  
 
 58  
     /**
 59  
      * Constructor.
 60  
      *
 61  
      * @param model
 62  
      *            The template model.
 63  
      */
 64  1
     public InsertDefinitionFMModel(org.apache.tiles.template.InsertDefinitionModel model) {
 65  1
         this.model = model;
 66  1
     }
 67  
 
 68  
     /** {@inheritDoc} */
 69  
     @SuppressWarnings("unchecked")
 70  
     @Override
 71  
     public void execute(Environment env, @SuppressWarnings("rawtypes") Map params, TemplateModel[] loopVars,
 72  
             TemplateDirectiveBody body) throws TemplateException, IOException {
 73  0
         AutotagRuntime<org.apache.tiles.request.Request> runtime = new org.apache.tiles.request.freemarker.autotag.FreemarkerAutotagRuntime();
 74  0
         if (runtime instanceof TemplateDirectiveModel) {
 75  0
             ((TemplateDirectiveModel) runtime).execute(env, params, loopVars, body);
 76  
         }
 77  0
         org.apache.tiles.request.Request request = runtime.createRequest();
 78  0
         ModelBody modelBody = runtime.createModelBody();
 79  0
         model.execute(
 80  
             runtime.getParameter("name", java.lang.String.class, null),
 81  
             runtime.getParameter("template", java.lang.String.class, null),
 82  
             runtime.getParameter("templateType", java.lang.String.class, null),
 83  
             runtime.getParameter("templateExpression", java.lang.String.class, null),
 84  
             runtime.getParameter("role", java.lang.String.class, null),
 85  
             runtime.getParameter("preparer", java.lang.String.class, null),
 86  
             runtime.getParameter("flush", java.lang.Boolean.class, false),
 87  
                 request, modelBody
 88  
         );
 89  0
     }
 90  
 }