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 java.io.IOException;
044: import javax.faces.component.UIComponent;
045: import javax.faces.context.FacesContext;
046: import javax.faces.context.ResponseWriter;
047: import com.sun.rave.web.ui.component.FrameSet;
048: import com.sun.rave.web.ui.util.RenderingUtilities;
049:
050: /**
051: * <p>Renderer for a {@link FrameSet} component.</p>
052: */
053:
054: public class FrameSetRenderer extends AbstractRenderer {
055:
056: // ======================================================== Static Variables
057:
058: /**
059: * <p>The set of String pass-through attributes to be rendered.</p>
060: */
061: private static final String stringAttributes[] = { "rows", "cols",
062: "borderColor" }; //NOI18N
063: private static final String integerAttributes[] = { "border",
064: "frameSpacing" }; //NOI18N
065: private static final String booleanAttributes[] = { "frameBorder" }; //NOI18N
066:
067: // -------------------------------------------------------- Renderer Methods
068:
069: /**
070: * <p>Render the appropriate element start for the outermost
071: * element.</p>
072: *
073: * @param context <code>FacesContext</code> for the current request
074: * @param component component to be rendered
075: * @param writer <code>ResponseWriter</code> to which the element
076: * start should be rendered
077: *
078: * @exception IOException if an input/output error occurs
079: */
080: protected void renderStart(FacesContext context,
081: UIComponent component, ResponseWriter writer)
082: throws IOException {
083: FrameSet frameset = (FrameSet) component;
084:
085: // I don't think this is the correct way to write the XML
086: // header /avk
087:
088: if (!RenderingUtilities.isPortlet(context)) {
089: writer.startElement("frameset", component);
090: }
091:
092: }
093:
094: /**
095: * <p>Render the appropriate element attributes, followed by the
096: * nested <code><head></code> element, plus the beginning
097: * of a nested <code><body></code> element.</p>
098: *
099: * @param context <code>FacesContext</code> for the current request
100: * @param component component to be rendered
101: * @param writer <code>ResponseWriter</code> to which the element
102: * start should be rendered
103: *
104: * @exception IOException if an input/output error occurs
105: */
106: protected void renderAttributes(FacesContext context,
107: UIComponent component, ResponseWriter writer)
108: throws IOException {
109:
110: FrameSet frameset = (FrameSet) component;
111:
112: // Render a nested "head" element
113: if (!RenderingUtilities.isPortlet(context)) {
114: //id
115: String id = frameset.getClientId(context);
116: if (id != null) {
117: writer.writeAttribute("id", id, null); //NOI18N
118: }
119: //class
120: String styleClass = frameset.getStyleClass();
121: if (styleClass != null) {
122: writer.writeAttribute("class", styleClass, null); //NOI18N
123: }
124: //style
125: String style = frameset.getStyle();
126: if (style != null) {
127: writer.writeAttribute("style", style, null); //NOI18N
128: }
129: //tooltip
130: String toolTip = frameset.getToolTip();
131: if (toolTip != null) {
132: writer.writeAttribute("title", toolTip, "toolTip"); //NOI18N
133: }
134: //write out the rest of the attributes
135: addStringAttributes(context, component, writer,
136: stringAttributes);
137: addBooleanAttributes(context, component, writer,
138: booleanAttributes);
139: addIntegerAttributes(context, component, writer,
140: integerAttributes);
141: writer.write("\n"); //NOI18N
142: }
143:
144: }
145:
146: /**
147: * <p>Render the appropriate element end.</p>
148: *
149: * @param context <code>FacesContext</code> for the current request
150: * @param component component to be rendered
151: * @param writer <code>ResponseWriter</code> to which the element
152: * start should be rendered
153: *
154: * @exception IOException if an input/output error occurs
155: */
156: protected void renderEnd(FacesContext context,
157: UIComponent component, ResponseWriter writer)
158: throws IOException {
159:
160: FrameSet frameset = (FrameSet) component;
161:
162: // End the outermost "html" element
163: if (!RenderingUtilities.isPortlet(context)) {
164: writer.endElement("frameset"); //NOI18N
165: writer.write("\n"); //NOI18N
166: }
167:
168: }
169:
170: // --------------------------------------------------------- Private Methods
171: }
|