Coverage Report - org.apache.tiles.velocity.template.InsertDefinitionDirective
 
Classes in this File Line Coverage Branch Coverage Complexity
InsertDefinitionDirective
0%
0/11
0%
0/2
1.333
 
 1  
 /*
 2  
  * This file was automatically generated by Apache Tiles Autotag.
 3  
  */
 4  
 package org.apache.tiles.velocity.template;
 5  
 
 6  
 import java.io.IOException;
 7  
 import java.io.Writer;
 8  
 
 9  
 import org.apache.tiles.autotag.core.runtime.ModelBody;
 10  
 import org.apache.tiles.autotag.core.runtime.AutotagRuntime;
 11  
 import org.apache.velocity.context.InternalContextAdapter;
 12  
 import org.apache.velocity.runtime.directive.Directive;
 13  
 import org.apache.velocity.runtime.parser.node.Node;
 14  
 
 15  
 /**
 16  
  * <p>
 17  
  * <strong>Insert a definition.</strong>
 18  
  * </p>
 19  
  * <p>
 20  
  * Insert a definition with the possibility to override and specify parameters
 21  
  * (called attributes). A definition can be seen as a (partially or totally)
 22  
  * filled template that can override or complete attribute values.
 23  
  * <code>&lt;tiles:insertDefinition&gt;</code> allows to define these attributes
 24  
  * and pass them to the inserted jsp page, called template. Attributes are
 25  
  * defined using nested tag <code>&lt;tiles:putAttribute&gt;</code> or
 26  
  * <code>&lt;tiles:putListAttribute&gt;</code>.
 27  
  * </p>
 28  
  * <p>
 29  
  * You must specify <code>name</code> tag attribute, for inserting a definition
 30  
  * from definitions factory.
 31  
  * </p>
 32  
  * <p>
 33  
  * <strong>Example : </strong>
 34  
  * </p>
 35  
  * 
 36  
  * <pre>
 37  
  * &lt;code&gt;
 38  
  *           &lt;tiles:insertDefinition name=&quot;.my.tiles.defininition flush=&quot;true&quot;&gt;
 39  
  *              &lt;tiles:putAttribute name=&quot;title&quot; value=&quot;My first page&quot; /&gt;
 40  
  *              &lt;tiles:putAttribute name=&quot;header&quot; value=&quot;/common/header.jsp&quot; /&gt;
 41  
  *              &lt;tiles:putAttribute name=&quot;footer&quot; value=&quot;/common/footer.jsp&quot; /&gt;
 42  
  *              &lt;tiles:putAttribute name=&quot;menu&quot; value=&quot;/basic/menu.jsp&quot; /&gt;
 43  
  *              &lt;tiles:putAttribute name=&quot;body&quot; value=&quot;/basic/helloBody.jsp&quot; /&gt;
 44  
  *           &lt;/tiles:insertDefinition&gt;
 45  
  *         &lt;/code&gt;
 46  
  * </pre>
 47  
  */
 48  0
 public class InsertDefinitionDirective extends Directive {
 49  
 
 50  
     /**
 51  
      * The template model.
 52  
      */
 53  0
     private org.apache.tiles.template.InsertDefinitionModel model = new org.apache.tiles.template.InsertDefinitionModel();
 54  
 
 55  
     /** {@inheritDoc} */
 56  
     @Override
 57  
     public String getName() {
 58  0
         return "tiles_insertDefinition";
 59  
     }
 60  
 
 61  
     /** {@inheritDoc} */
 62  
     @Override
 63  
     public int getType() {
 64  0
         return BLOCK;
 65  
     }
 66  
 
 67  
     /** {@inheritDoc} */
 68  
     @Override
 69  
     public boolean render(InternalContextAdapter context, Writer writer, Node node)
 70  
             throws IOException {
 71  0
         AutotagRuntime<org.apache.tiles.request.Request> runtime = new org.apache.tiles.request.velocity.autotag.VelocityAutotagRuntime();
 72  0
         if (runtime instanceof Directive) {
 73  0
             ((Directive) runtime).render(context, writer, node);
 74  
         }
 75  0
         org.apache.tiles.request.Request request = runtime.createRequest();
 76  0
         ModelBody modelBody = runtime.createModelBody();
 77  0
         model.execute(
 78  
             runtime.getParameter("name", java.lang.String.class, null),
 79  
             runtime.getParameter("template", java.lang.String.class, null),
 80  
             runtime.getParameter("templateType", java.lang.String.class, null),
 81  
             runtime.getParameter("templateExpression", java.lang.String.class, null),
 82  
             runtime.getParameter("role", java.lang.String.class, null),
 83  
             runtime.getParameter("preparer", java.lang.String.class, null),
 84  
             runtime.getParameter("flush", java.lang.Boolean.class, false),
 85  
             request, modelBody
 86  
         );
 87  0
         return true;
 88  
     }
 89  
 }