01: /**
02: * Copyright 2006 Webmedia Group Ltd.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: **/package org.araneaframework.example.main.web;
16:
17: import org.apache.commons.lang.StringUtils;
18: import org.araneaframework.AraneaVersion;
19: import org.araneaframework.OutputData;
20: import org.araneaframework.example.common.framework.TemplateMenuWidget;
21: import org.araneaframework.http.HttpInputData;
22: import org.araneaframework.uilib.core.BaseUIWidget;
23: import org.araneaframework.uilib.core.MenuContext;
24:
25: /**
26: * @author Taimo Peelo (taimo@araneaframework.org)
27: */
28: public class FooterWidget extends BaseUIWidget {
29: private static final long serialVersionUID = 1L;
30:
31: protected void init() throws Exception {
32: putViewData("aranea-version", AraneaVersion.getVersion());
33: setViewSelector("mainlayout/footer");
34: }
35:
36: protected void render(OutputData output) throws Exception {
37: TemplateMenuWidget menuWidget = (TemplateMenuWidget) getEnvironment()
38: .getEntry(MenuContext.class);
39:
40: /* widget source */
41: String flowClassName = menuWidget.getFlowClassName();
42: if (flowClassName != null) {
43: String path = StringUtils.replace(StringUtils.replace(
44: flowClassName, ".class", ""), ".", "/");
45: while (path.lastIndexOf('$') != -1) {
46: int index = path.lastIndexOf('$');
47: path = path.substring(0, index);
48: }
49:
50: StringBuffer reqUrl = new StringBuffer(
51: ((HttpInputData) getInputData()).getContextURL());
52: reqUrl.append("/src/");
53: reqUrl.append(path);
54: reqUrl.append(".javas");
55:
56: StringBuffer windowOpen = new StringBuffer("window.open('")
57: .append(reqUrl)
58: .append(
59: "', 'widgetSource', 'width=900,height=800,scrollbars=yes')");
60:
61: StringBuffer srcLink = new StringBuffer(
62: "<a href=\"javascript:\" onclick=\"").append(
63: windowOpen).append("; return false;\">");
64: srcLink.append("Widget source").append("</a>");
65:
66: putViewDataOnce("srcLink", srcLink.toString());
67: }
68:
69: /* view source */
70: String viewSelector = menuWidget.getFlowViewSelector();
71: if (viewSelector != null) {
72: StringBuffer reqUrl = new StringBuffer(
73: ((HttpInputData) getInputData()).getContextURL());
74: reqUrl.append("/jsp/");
75: reqUrl.append(viewSelector);
76: reqUrl.append(".xmls");
77:
78: StringBuffer windowOpen = new StringBuffer("window.open('")
79: .append(reqUrl)
80: .append(
81: "', 'templateSource', 'width=900,height=800,scrollbars=yes')");
82:
83: StringBuffer templateSrcLink = new StringBuffer(
84: "<a href=\"javascript:\" onclick=\"").append(
85: windowOpen).append("; return false;\">");
86: templateSrcLink.append("Template source").append("</a>");
87:
88: putViewDataOnce("templateSrcLink", templateSrcLink
89: .toString());
90: }
91:
92: super.render(output);
93: }
94: }
|