001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041: package com.sun.rave.web.ui.renderer;
042:
043: import com.sun.rave.web.ui.component.Html;
044: import com.sun.rave.web.ui.theme.Theme;
045: import com.sun.rave.web.ui.theme.ThemeImages;
046: import com.sun.rave.web.ui.theme.ThemeStyles;
047: import com.sun.rave.web.ui.util.MessageUtil;
048:
049: import java.io.IOException;
050: import java.text.MessageFormat;
051: import java.util.ArrayList;
052: import java.util.Iterator;
053: import java.util.List;
054:
055: import javax.faces.component.EditableValueHolder;
056: import javax.faces.component.NamingContainer;
057: import javax.faces.component.UIComponent;
058: import javax.faces.component.UIParameter;
059: import javax.faces.context.FacesContext;
060: import javax.faces.context.ResponseWriter;
061:
062: import com.sun.rave.web.ui.util.RenderingUtilities;
063:
064: /**
065: * <p>Renderer for a {@link Html} component.</p>
066: */
067:
068: public class HtmlRenderer extends AbstractRenderer {
069:
070: // ======================================================== Static Variables
071:
072: /**
073: * <p>The set of String pass-through attributes to be rendered.</p>
074: */
075: private static final String stringAttributes[] = { "xmlns", "lang" }; //NOI18N
076:
077: // -------------------------------------------------------- Renderer Methods
078:
079: /**
080: * <p>Render the appropriate element start, depending on whether the
081: * <code>for</code> property is set or not.</p>
082: *
083: * @param context <code>FacesContext</code> for the current request
084: * @param component component to render.
085: * @param writer <code>ResponseWriter</code> to which the element
086: * start should be rendered
087: *
088: * @exception IOException if an input/output error occurs
089: */
090: protected void renderStart(FacesContext context,
091: UIComponent component, ResponseWriter writer)
092: throws IOException {
093:
094: // Start the appropriate element
095: if (!RenderingUtilities.isPortlet(context)) {
096: writer.startElement("html", component); //NOI18N
097: }
098: }
099:
100: /**
101: * <p>Render the appropriate element attributes,
102: *
103: * @param context <code>FacesContext</code> for the current request
104: * @param component component to be rendered
105: * submitted value is to be stored
106: * @param writer <code>ResponseWriter</code> to which the element
107: * start should be rendered
108: *
109: * @exception IOException if an input/output error occurs
110: */
111: protected void renderAttributes(FacesContext context,
112: UIComponent component, ResponseWriter writer)
113: throws IOException {
114:
115: if (!RenderingUtilities.isPortlet(context)) {
116: addStringAttributes(context, component, writer,
117: stringAttributes);
118: writer.write("\n");
119: }
120: }
121:
122: /**
123: * <p>Render the appropriate element end, depending on whether the
124: * <code>for</code> property is set or not.</p>
125: *
126: * @param context <code>FacesContext</code> for the current request
127: * @param component component to be rendered
128: * @param writer <code>ResponseWriter</code> to which the element
129: * start should be rendered
130: *
131: * @exception IOException if an input/output error occurs
132: */
133: protected void renderEnd(FacesContext context,
134: UIComponent component, ResponseWriter writer)
135: throws IOException {
136:
137: if (!RenderingUtilities.isPortlet(context)) {
138: writer.endElement("html"); //NOI18N
139: writer.write("\n"); //NOI18N
140: }
141: }
142:
143: // --------------------------------------------------------- Private Methods
144:
145: }
|