Coverage Report - org.apache.tiles.freemarker.template.PutAttributeFMModel
 
Classes in this File Line Coverage Branch Coverage Complexity
PutAttributeFMModel
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>Put an attribute in enclosing attribute container tag.</strong>
 21  
  * </p>
 22  
  * <p>
 23  
  * Enclosing attribute container tag can be :
 24  
  * <ul>
 25  
  * <li>&lt;initContainer&gt;</li>
 26  
  * <li>&lt;definition&gt;</li>
 27  
  * <li>&lt;insertAttribute&gt;</li>
 28  
  * <li>&lt;insertDefinition&gt;</li>
 29  
  * <li>&lt;putListAttribute&gt;</li>
 30  
  * </ul>
 31  
  * (or any other tag which implements the <code>PutAttributeTagParent</code>
 32  
  * interface. Exception is thrown if no appropriate tag can be found.
 33  
  * </p>
 34  
  * <p>
 35  
  * Put tag can have following atributes :
 36  
  * <ul>
 37  
  * <li>name : Name of the attribute</li>
 38  
  * <li>value : value to put as attribute</li>
 39  
  * <li>type : value type. Possible type are : string (value is used as direct
 40  
  * string), template (value is used as a page url to insert), definition (value
 41  
  * is used as a definition name to insert), object (value is used as it is)</li>
 42  
  * <li>role : Role to check when 'insertAttribute' will be called.</li>
 43  
  * </ul>
 44  
  * </p>
 45  
  * <p>
 46  
  * Value can also come from tag body. Tag body is taken into account only if
 47  
  * value is not set by one of the tag attributes. In this case Attribute type is
 48  
  * "string", unless tag body define another type.
 49  
  * </p>
 50  
  */
 51  
 public class PutAttributeFMModel implements TemplateDirectiveModel {
 52  
 
 53  
     /**
 54  
      * The template model.
 55  
      */
 56  
     private org.apache.tiles.template.PutAttributeModel model;
 57  
 
 58  
     /**
 59  
      * Constructor.
 60  
      *
 61  
      * @param model
 62  
      *            The template model.
 63  
      */
 64  1
     public PutAttributeFMModel(org.apache.tiles.template.PutAttributeModel 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("value", java.lang.Object.class, null),
 82  
             runtime.getParameter("expression", java.lang.String.class, null),
 83  
             runtime.getParameter("role", java.lang.String.class, null),
 84  
             runtime.getParameter("type", java.lang.String.class, null),
 85  
             runtime.getParameter("cascade", java.lang.Boolean.class, false),
 86  
                 request, modelBody
 87  
         );
 88  0
     }
 89  
 }