Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
InsertDefinitionFMModel |
|
| 1.5;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><tiles:insertDefinition></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><tiles:putAttribute></code> or | |
29 | * <code><tiles:putListAttribute></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 | * <code> | |
41 | * <tiles:insertDefinition name=".my.tiles.defininition flush="true"> | |
42 | * <tiles:putAttribute name="title" value="My first page" /> | |
43 | * <tiles:putAttribute name="header" value="/common/header.jsp" /> | |
44 | * <tiles:putAttribute name="footer" value="/common/footer.jsp" /> | |
45 | * <tiles:putAttribute name="menu" value="/basic/menu.jsp" /> | |
46 | * <tiles:putAttribute name="body" value="/basic/helloBody.jsp" /> | |
47 | * </tiles:insertDefinition> | |
48 | * </code> | |
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 | } |