1 | |
|
2 | |
|
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 | |
|
20 | |
|
21 | |
|
22 | |
|
23 | |
|
24 | |
|
25 | |
|
26 | |
|
27 | |
public class DefinitionFMModel implements TemplateDirectiveModel { |
28 | |
|
29 | |
|
30 | |
|
31 | |
|
32 | |
private org.apache.tiles.template.DefinitionModel model; |
33 | |
|
34 | |
|
35 | |
|
36 | |
|
37 | |
|
38 | |
|
39 | |
|
40 | 1 | public DefinitionFMModel(org.apache.tiles.template.DefinitionModel model) { |
41 | 1 | this.model = model; |
42 | 1 | } |
43 | |
|
44 | |
|
45 | |
@SuppressWarnings("unchecked") |
46 | |
@Override |
47 | |
public void execute(Environment env, @SuppressWarnings("rawtypes") Map params, TemplateModel[] loopVars, |
48 | |
TemplateDirectiveBody body) throws TemplateException, IOException { |
49 | 0 | AutotagRuntime<org.apache.tiles.request.Request> runtime = new org.apache.tiles.request.freemarker.autotag.FreemarkerAutotagRuntime(); |
50 | 0 | if (runtime instanceof TemplateDirectiveModel) { |
51 | 0 | ((TemplateDirectiveModel) runtime).execute(env, params, loopVars, body); |
52 | |
} |
53 | 0 | org.apache.tiles.request.Request request = runtime.createRequest(); |
54 | 0 | ModelBody modelBody = runtime.createModelBody(); |
55 | 0 | model.execute( |
56 | |
runtime.getParameter("name", java.lang.String.class, null), |
57 | |
runtime.getParameter("template", java.lang.String.class, null), |
58 | |
runtime.getParameter("role", java.lang.String.class, null), |
59 | |
runtime.getParameter("extends", java.lang.String.class, null), |
60 | |
runtime.getParameter("preparer", java.lang.String.class, null), |
61 | |
request, modelBody |
62 | |
); |
63 | 0 | } |
64 | |
} |