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 | |
|
28 | |
|
29 | |
|
30 | |
|
31 | |
|
32 | |
|
33 | |
|
34 | |
|
35 | |
|
36 | |
|
37 | |
|
38 | |
|
39 | |
|
40 | |
|
41 | |
|
42 | |
|
43 | |
|
44 | |
|
45 | |
|
46 | |
|
47 | |
|
48 | |
|
49 | |
|
50 | |
|
51 | |
public class PutAttributeFMModel implements TemplateDirectiveModel { |
52 | |
|
53 | |
|
54 | |
|
55 | |
|
56 | |
private org.apache.tiles.template.PutAttributeModel model; |
57 | |
|
58 | |
|
59 | |
|
60 | |
|
61 | |
|
62 | |
|
63 | |
|
64 | 1 | public PutAttributeFMModel(org.apache.tiles.template.PutAttributeModel model) { |
65 | 1 | this.model = model; |
66 | 1 | } |
67 | |
|
68 | |
|
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 | |
} |