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