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.IFrame;
048: import com.sun.rave.web.ui.util.RenderingUtilities;
049:
050: /**
051: * <p>Renderer for a {@link IFrameRenderer} component.</p>
052: */
053:
054: public class IFrameRenderer extends FrameRenderer {
055:
056: // -------------------------------------------------------- Renderer Methods
057:
058: /**
059: * <p>Render the appropriate element start for the outermost
060: * element.</p>
061: *
062: * @param context <code>FacesContext</code> for the current request
063: * @param component component to be rendered
064: * @param writer <code>ResponseWriter</code> to which the element
065: * start should be rendered
066: *
067: * @exception IOException if an input/output error occurs
068: */
069: protected void renderStart(FacesContext context,
070: UIComponent component, ResponseWriter writer)
071: throws IOException {
072: IFrame frame = (IFrame) component;
073:
074: // I don't think this is the correct way to write the XML
075: // header /avk
076:
077: if (!RenderingUtilities.isPortlet(context)) {
078: writer.startElement("iframe", component);
079: }
080:
081: }
082:
083: /**
084: * <p>Render the appropriate element attributes, followed by the
085: * nested <code><head></code> element, plus the beginning
086: * of a nested <code><body></code> element.</p>
087: *
088: * @param context <code>FacesContext</code> for the current request
089: * @param component component to be rendered
090: * @param writer <code>ResponseWriter</code> to which the element
091: * start should be rendered
092: *
093: * @exception IOException if an input/output error occurs
094: */
095: protected void renderAttributes(FacesContext context,
096: UIComponent component, ResponseWriter writer)
097: throws IOException {
098:
099: IFrame frame = (IFrame) component;
100:
101: super .renderAttributes(context, component, writer);
102:
103: // Render a nested "head" element
104: if (!RenderingUtilities.isPortlet(context)) {
105: //align
106: String align = frame.getAlign();
107: if (align != null) {
108: writer.writeAttribute("align", align, null); //NOI18N
109: }
110:
111: //marginWidth
112: String width = frame.getWidth();
113: if (width != null) {
114: writer.writeAttribute("width", width.toString(), null); //NOI18N
115: }
116: //marginHeight
117: String height = frame.getHeight();
118: if (height != null) {
119: writer
120: .writeAttribute("height", height.toString(),
121: null); //NOI18N
122: }
123: }
124: }
125:
126: /**
127: * <p>Render the appropriate element end.</p>
128: *
129: * @param context <code>FacesContext</code> for the current request
130: * @param component component to be rendered
131: * @param writer <code>ResponseWriter</code> to which the element
132: * start should be rendered
133: *
134: * @exception IOException if an input/output error occurs
135: */
136: protected void renderEnd(FacesContext context,
137: UIComponent component, ResponseWriter writer)
138: throws IOException {
139:
140: // End the outermost "html" element
141: if (!RenderingUtilities.isPortlet(context)) {
142: writer.endElement("iframe"); //NOI18N
143: writer.write("\n"); //NOI18N
144: }
145:
146: }
147:
148: // ------------------------------------------------------- Protected Methods
149:
150: protected void renderResizeAttribute(ResponseWriter writer,
151: UIComponent comp) throws IOException {
152: //intentionally blank
153: }
154:
155: }
|