All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.sakaiproject.jsf.renderer.AppletRenderer Maven / Gradle / Ivy

Go to download

This is the Maven project for the custom JSF widgets. The widgets and the resources projects are closely tied together. These widgets will be deployed as a jar file containing Sakai JSF widgets (components). Web applications can include this jar in order to use the Sakai JSF widgets in a JSF tool.

There is a newer version: 23.3
Show newest version
/**********************************************************************************
* $URL$
* $Id$
***********************************************************************************
*
 * Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008 The Sakai Foundation
 *
 * Licensed under the Educational Community License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *       http://www.opensource.org/licenses/ECL-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
*
**********************************************************************************/


package org.sakaiproject.jsf.renderer;

import java.io.IOException;
import javax.faces.component.UIComponent;
import javax.faces.component.UIOutput;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
import javax.faces.render.Renderer;

import org.sakaiproject.jsf.util.RendererUtil;
import java.util.Map;
import java.util.Map.Entry;
import java.util.HashMap;
import java.util.Iterator;
import java.util.StringTokenizer;

/**
 * 

Description:

*

Render an applet in a browser-indepemdent way * *

Copyright: Copyright (c) 2005

*

Organization: Sakai Project

* @author Ed Smiley * @version $Id$ */ public class AppletRenderer extends Renderer { private static final String IE_CODEBASE = "http://java.sun.com/products/plugin/1.4/jinstall-14-win32.cab#Version=1,4,0,mn"; private static final String NS_PLUGINSPAGE = "http://java.sun.com/products/plugin/1.4/plugin-install.html"; private static final String VERSION = "1.4"; private static final String DEFAULT_WIDTH = "200"; private static final String DEFAULT_HEIGHT = "200"; private static final String DEFAULT_VSPACE = "0"; private static final String DEFAULT_HSPACE = "0"; public boolean supportsComponentType(UIComponent component) { return (component instanceof UIOutput); } /** * @todo apply attributes *

Faces render output method .

*

Method Generator: org.sakaiproject.jsf.devtool.RenderMaker

* * @param context FacesContext for the current request * @param component UIComponent being rendered * * @throws IOException if an input/output error occurs */ public void encodeBegin(FacesContext context, UIComponent component) throws IOException { if (!component.isRendered()) { return; } String width = (String) RendererUtil.getDefaultedAttribute(context, component, "width", DEFAULT_WIDTH); String height = (String) RendererUtil.getDefaultedAttribute(context, component, "height", DEFAULT_HEIGHT); String vspace = (String) RendererUtil.getDefaultedAttribute(context, component, "vspace", DEFAULT_VSPACE); String hspace = (String) RendererUtil.getDefaultedAttribute(context, component, "hspace", DEFAULT_HSPACE); String javaClass = (String) RendererUtil.getAttribute(context, component, "javaClass"); String javaArchive = (String) RendererUtil.getAttribute(context, component, "javaArchive"); String codebase = (String) RendererUtil.getAttribute(context, component, "codebase"); String paramList = (String) RendererUtil.getAttribute(context, component, "paramList"); String name = (String) RendererUtil.getAttribute(context, component, "name"); Map appParamMap = makeAppletParameters(paramList); if(null!=codebase) appParamMap.put("codebase", codebase); if(null!=javaArchive) appParamMap.put("archive", javaArchive); //if(null!=name) appParamMap.put("id", name); appParamMap.put("code", javaClass); ResponseWriter writer = context.getResponseWriter(); renderApplet(width, height, vspace, hspace, codebase, javaClass, javaArchive, name, appParamMap, writer); } /** * Accept a comma separated list of name value pairs. * @todo quotations to escape out "," and "=". * Usage: // // // // // // // // // No Java 2 SDK, Standard Edition v 1.4 support for APPLET!! // // // // private void renderApplet(String width, String height, String vspace, String hspace, String codebase, String javaClass, String javaArchive, String name, Map appParamMap, ResponseWriter writer) throws IOException { writer.write(""); writer.write(""); // writer.write(" "); // writer.write(" "); writer.write( " "); renderObjectParams(writer, appParamMap); writer.write(""); writer.write(""); writer.write(""); writer.write(""); writer.write(" <font color=\"red\">"); writer.write(" Note: Requires Java Plug-in " + VERSION + "."); writer.write(" </b></font><br/>"); writer.write(""); writer.write(""); writer.write(""); } /** * Render Map of Embed tag params, * @param writer * @param appParamMap * @throws IOException */ private void renderEmbedParams(ResponseWriter writer, Map appParamMap) throws IOException { Iterator paramIter = appParamMap.entrySet().iterator(); while (paramIter.hasNext()) { Entry entrySet = (Entry) paramIter.next(); String name = (String) entrySet.getKey(); String value = (String) entrySet.getValue(); writer.write(" " + name + "=\"" + value + "\" "); } } /** * Render Map of Object PARAMs. * @param writer * @param appParamMap * @throws IOException */ private void renderObjectParams(ResponseWriter writer, Map appParamMap) throws IOException { Iterator iter = appParamMap.entrySet().iterator(); while (iter.hasNext()) { Entry entrySet = (Entry) iter.next(); String name = (String) entrySet.getKey(); String value = (String) entrySet.getValue(); writer.write(" "); } } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy