1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.krad.uif.freemarker;
17
18 import java.io.IOException;
19 import java.io.Serializable;
20 import java.util.Map;
21
22 import org.kuali.rice.krad.uif.component.Component;
23
24 import freemarker.core.Environment;
25 import freemarker.core.InlineTemplateAdaptor;
26 import freemarker.template.TemplateException;
27 import freemarker.template.TemplateModel;
28
29
30
31
32
33
34 public class FreeMarkerTemplateAdaptor implements InlineTemplateAdaptor, Serializable {
35
36 private static final long serialVersionUID = -4442716566711789593L;
37
38
39
40
41
42
43 @Override
44 public void accept(Environment env) throws TemplateException, IOException {
45 Component component = FreeMarkerInlineRenderUtils.resolve(env, "component", Component.class);
46
47 if (component == null) {
48 return;
49 }
50
51 String body = FreeMarkerInlineRenderUtils.resolve(env, "body", String.class);
52 boolean componentUpdate = Boolean.TRUE.equals(FreeMarkerInlineRenderUtils.resolve(env, "componentUpdate",
53 Boolean.class));
54 boolean includeSrc = Boolean.TRUE.equals(FreeMarkerInlineRenderUtils.resolve(env, "includeSrc", Boolean.class));
55 @SuppressWarnings("unchecked")
56 Map<String, TemplateModel> tmplParms = FreeMarkerInlineRenderUtils.resolve(env, "tmplParms", Map.class);
57 FreeMarkerInlineRenderUtils.renderTemplate(env, component, body, componentUpdate, includeSrc, tmplParms);
58 }
59
60 }