1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.springframework.extensions.surf.render.bean;
20
21 import java.io.IOException;
22 import java.io.PrintWriter;
23
24 import org.springframework.extensions.surf.WebFrameworkConstants;
25 import org.springframework.extensions.surf.render.RenderContext;
26 import org.springframework.extensions.surf.render.bean.RegionRenderer;
27 import org.springframework.extensions.surf.studio.WebStudioService;
28
29
30
31
32
33
34
35
36
37
38 public class WebStudioRegionRenderer extends RegionRenderer
39 {
40 private WebStudioService webStudioService = null;
41
42
43
44
45
46
47 public void setWebStudioService(WebStudioService webStudioService)
48 {
49 this.webStudioService = webStudioService;
50 }
51
52
53
54
55
56
57 protected WebStudioService getWebStudioService()
58 {
59 return this.webStudioService;
60 }
61
62
63
64
65
66
67 public void postProcess(RenderContext context) throws IOException
68 {
69
70 boolean webStudioEnabled = true;
71 if (webStudioEnabled)
72 {
73
74 if (!context.isPassiveMode())
75 {
76
77 String htmlId = (String) context
78 .getValue(WebFrameworkConstants.RENDER_DATA_HTMLID);
79
80
81 String regionId = (String) context
82 .getValue(WebFrameworkConstants.RENDER_DATA_REGION_ID);
83 String regionScopeId = (String) context
84 .getValue(WebFrameworkConstants.RENDER_DATA_REGION_SCOPE_ID);
85 String regionSourceId = (String) context
86 .getValue(WebFrameworkConstants.RENDER_DATA_REGION_SOURCE_ID);
87
88
89 PrintWriter writer = context.getResponse().getWriter();
90 writer
91 .println("<script type='text/javascript'>");
92
93 if (regionId != null && regionScopeId != null
94 && regionSourceId != null)
95 {
96 writer.println("if(typeof WebStudio != \"undefined\"){");
97 writer.println("WebStudio.configureRegion('" + htmlId + "', '"
98 + regionId + "', '" + regionScopeId + "', '"
99 + regionSourceId + "');");
100 writer.println("}");
101 }
102
103 writer.println("</script>");
104 writer.flush();
105 }
106 }
107 }
108 }