1 |
| |
2 |
| |
3 |
| |
4 |
| |
5 |
| |
6 |
| |
7 |
| |
8 |
| |
9 |
| |
10 |
| |
11 |
| |
12 |
| |
13 |
| |
14 |
| |
15 |
| package org.apache.tapestry.portlet; |
16 |
| |
17 |
| import java.io.IOException; |
18 |
| import java.io.PrintWriter; |
19 |
| import java.util.Date; |
20 |
| |
21 |
| import org.apache.tapestry.IMarkupWriter; |
22 |
| import org.apache.tapestry.IPage; |
23 |
| import org.apache.tapestry.IRequestCycle; |
24 |
| import org.apache.tapestry.Tapestry; |
25 |
| import org.apache.tapestry.TapestryUtils; |
26 |
| import org.apache.tapestry.asset.AssetFactory; |
27 |
| import org.apache.tapestry.markup.MarkupWriterSource; |
28 |
| import org.apache.tapestry.util.ContentType; |
29 |
| import org.apache.tapestry.util.PageRenderSupportImpl; |
30 |
| import org.apache.tapestry.web.WebResponse; |
31 |
| |
32 |
| |
33 |
| |
34 |
| |
35 |
| |
36 |
| |
37 |
| |
38 |
| |
39 |
| |
40 |
| public class PortletRendererImpl implements PortletRenderer |
41 |
| { |
42 |
| private WebResponse _response; |
43 |
| |
44 |
| private MarkupWriterSource _markupWriterSource; |
45 |
| |
46 |
| private AssetFactory _assetFactory; |
47 |
| |
48 |
| private String _applicationId; |
49 |
| |
50 |
1
| public void renderPage(IRequestCycle cycle, String pageName) throws IOException
|
51 |
| { |
52 |
1
| cycle.activate(pageName);
|
53 |
| |
54 |
1
| IPage page = cycle.getPage();
|
55 |
| |
56 |
1
| ContentType contentType = page.getResponseContentType();
|
57 |
| |
58 |
1
| PrintWriter printWriter = _response.getPrintWriter(contentType);
|
59 |
| |
60 |
1
| IMarkupWriter writer = _markupWriterSource.newMarkupWriter(printWriter, contentType);
|
61 |
| |
62 |
1
| String namespace = _response.getNamespace();
|
63 |
| |
64 |
1
| PageRenderSupportImpl support = new PageRenderSupportImpl(_assetFactory, namespace, null);
|
65 |
| |
66 |
1
| TapestryUtils.storePageRenderSupport(cycle, support);
|
67 |
| |
68 |
1
| IMarkupWriter nested = writer.getNestedWriter();
|
69 |
| |
70 |
1
| cycle.renderPage(nested);
|
71 |
| |
72 |
1
| String id = "Tapestry Portlet " + _applicationId + " " + namespace;
|
73 |
| |
74 |
1
| writer.comment("BEGIN " + id);
|
75 |
1
| writer.comment("Page: " + page.getPageName());
|
76 |
1
| writer.comment("Generated: " + new Date());
|
77 |
1
| writer.comment("Framework version: " + Tapestry.VERSION);
|
78 |
| |
79 |
1
| support.writeBodyScript(writer, cycle);
|
80 |
| |
81 |
1
| nested.close();
|
82 |
| |
83 |
1
| support.writeInitializationScript(writer);
|
84 |
| |
85 |
1
| writer.comment("END " + id);
|
86 |
| |
87 |
1
| writer.close();
|
88 |
| |
89 |
| |
90 |
| } |
91 |
| |
92 |
1
| public void setMarkupWriterSource(MarkupWriterSource markupWriterSource)
|
93 |
| { |
94 |
1
| _markupWriterSource = markupWriterSource;
|
95 |
| } |
96 |
| |
97 |
1
| public void setResponse(WebResponse response)
|
98 |
| { |
99 |
1
| _response = response;
|
100 |
| } |
101 |
| |
102 |
1
| public void setAssetFactory(AssetFactory assetFactory)
|
103 |
| { |
104 |
1
| _assetFactory = assetFactory;
|
105 |
| } |
106 |
| |
107 |
1
| public void setApplicationId(String applicationId)
|
108 |
| { |
109 |
1
| _applicationId = applicationId;
|
110 |
| } |
111 |
| } |