001: /**********************************************************************************
002: * $URL: https://source.sakaiproject.org/svn/help/tags/sakai_2-4-1/help-tool/src/java/org/sakaiproject/jsf/help/HelpFrameSetRender.java $
003: * $Id: HelpFrameSetRender.java 28753 2007-04-12 02:02:54Z ajpoland@iupui.edu $
004: ***********************************************************************************
005: *
006: * Copyright (c) 2003, 2004 The Sakai Foundation.
007: *
008: * Licensed under the Educational Community License, Version 1.0 (the "License");
009: * you may not use this file except in compliance with the License.
010: * You may obtain a copy of the License at
011: *
012: * http://www.opensource.org/licenses/ecl1.php
013: *
014: * Unless required by applicable law or agreed to in writing, software
015: * distributed under the License is distributed on an "AS IS" BASIS,
016: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017: * See the License for the specific language governing permissions and
018: * limitations under the License.
019: *
020: **********************************************************************************/package org.sakaiproject.jsf.help;
021:
022: import java.io.IOException;
023:
024: import javax.faces.application.Application;
025: import javax.faces.component.UIComponent;
026: import javax.faces.component.UIData;
027: import javax.faces.context.FacesContext;
028: import javax.faces.context.ResponseWriter;
029: import javax.faces.el.ValueBinding;
030: import javax.faces.render.Renderer;
031: import javax.servlet.http.HttpServletRequest;
032:
033: import org.sakaiproject.api.app.help.HelpManager;
034: import org.sakaiproject.component.cover.ServerConfigurationService;
035: import org.sakaiproject.event.cover.EventTrackingService;
036:
037: /**
038: * render help frame set
039: * @version $Id: HelpFrameSetRender.java 28753 2007-04-12 02:02:54Z ajpoland@iupui.edu $
040: */
041: public class HelpFrameSetRender extends Renderer {
042: /**
043: * supports component type
044: * @param component
045: * @return true if supported
046: */
047: public boolean supportsComponentType(UIComponent component) {
048: return (component instanceof UIData);
049: }
050:
051: /**
052: * @see javax.faces.render.Renderer#encodeBegin(javax.faces.context.FacesContext, javax.faces.component.UIComponent)
053: */
054: public void encodeBegin(FacesContext context, UIComponent component)
055: throws IOException {
056: ResponseWriter writer = context.getResponseWriter();
057: String helpWindowTitle = (String) component.getAttributes()
058: .get("helpWindowTitle");
059: String searchToolUrl = (String) component.getAttributes().get(
060: "searchToolUrl");
061: String tocToolUrl = (String) component.getAttributes().get(
062: "tocToolUrl");
063: String helpUrl = (String) component.getAttributes().get(
064: "helpUrl");
065:
066: String helpParameter = ((HttpServletRequest) context
067: .getExternalContext().getRequest())
068: .getParameter("help");
069:
070: String welcomepage = ServerConfigurationService
071: .getString("help.welcomepage");
072:
073: if ("".equals(welcomepage)) {
074: welcomepage = "html/help.html";
075: }
076:
077: tocToolUrl = tocToolUrl + "?help=" + helpParameter;
078:
079: EventTrackingService.post(EventTrackingService.newEvent(
080: "help.access", helpParameter, false));
081:
082: helpWindowTitle = ServerConfigurationService
083: .getString("ui.service")
084: + " Help";
085:
086: writer
087: .write("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Frameset//EN\" \"http://www.w3.org/TR/html4/frameset.dtd\">\n");
088: writer.write("<html><head><title>" + helpWindowTitle
089: + "</title></head>\n");
090: writer
091: .write("<FRAMESET cols=\"30%, 70%\"><FRAMESET rows=\"250, 350\">");
092: writer.write("<FRAME src=\"" + searchToolUrl
093: + "\" name=\"search\">");
094: writer.write("<FRAME src=\"" + tocToolUrl + "\" name=\"toc\">");
095: writer.write("</FRAMESET>\n");
096:
097: Application app = context.getApplication();
098: ValueBinding binding = app
099: .createValueBinding("#{Components['org.sakaiproject.api.app.help.HelpManager']}");
100: HelpManager manager = (HelpManager) binding.getValue(context);
101:
102: if (manager.getWelcomePage() == null) {
103: writer.write("<FRAME src=\"" + welcomepage
104: + "\" name=\"content\">");
105: } else {
106: writer
107: .write("<FRAME src=\"content.hlp?docId="
108: + manager.getWelcomePage()
109: + "\" name=\"content\">");
110: }
111:
112: writer.write("</FRAMESET></html>\n");
113: }
114: }
|