001    package org.apache.myfaces.tobago.renderkit.html.scarborough.standard.tag;
002    
003    /*
004     * Licensed to the Apache Software Foundation (ASF) under one or more
005     * contributor license agreements.  See the NOTICE file distributed with
006     * this work for additional information regarding copyright ownership.
007     * The ASF licenses this file to You under the Apache License, Version 2.0
008     * (the "License"); you may not use this file except in compliance with
009     * the License.  You may obtain a copy of the License at
010     *
011     *      http://www.apache.org/licenses/LICENSE-2.0
012     *
013     * Unless required by applicable law or agreed to in writing, software
014     * distributed under the License is distributed on an "AS IS" BASIS,
015     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
016     * See the License for the specific language governing permissions and
017     * limitations under the License.
018     */
019    
020    import org.apache.myfaces.tobago.component.Attributes;
021    import org.apache.myfaces.tobago.component.UIObject;
022    import org.apache.myfaces.tobago.context.ResourceManagerUtils;
023    import org.apache.myfaces.tobago.renderkit.LayoutComponentRendererBase;
024    import org.apache.myfaces.tobago.renderkit.css.Classes;
025    import org.apache.myfaces.tobago.renderkit.css.Style;
026    import org.apache.myfaces.tobago.renderkit.html.HtmlAttributes;
027    import org.apache.myfaces.tobago.renderkit.html.HtmlElements;
028    import org.apache.myfaces.tobago.renderkit.html.util.HtmlRendererUtils;
029    import org.apache.myfaces.tobago.webapp.TobagoResponseWriter;
030    
031    import javax.faces.component.UIComponent;
032    import javax.faces.context.FacesContext;
033    import java.io.IOException;
034    
035    public class ObjectRenderer extends LayoutComponentRendererBase {
036      public void encodeEnd(FacesContext facesContext, UIComponent component) throws IOException {
037        UIObject object = (UIObject) component;
038        TobagoResponseWriter writer = HtmlRendererUtils.getTobagoResponseWriter(facesContext);
039    
040        writer.startElement(HtmlElements.IFRAME, object);
041        writer.writeIdAttribute(object.getClientId(facesContext));
042        writer.writeNameAttribute(object.getClientId(facesContext));
043        Object src = object.getSrc();
044        if (src != null) {
045          writer.writeAttribute(HtmlAttributes.SRC, String.valueOf(src), true);
046        } else {
047          writer.writeAttribute(HtmlAttributes.SRC, ResourceManagerUtils.getBlankPage(facesContext), false);
048        }
049        writer.writeClassAttribute(Classes.create(object));
050        Style style = new Style(facesContext, object);
051        writer.writeStyleAttribute(style);
052    
053        String noframes = ResourceManagerUtils.getPropertyNotNull(
054            facesContext, "tobago", "browser.noframe.message.prefix");
055        writer.writeText(noframes + " ");
056        writer.startElement(HtmlElements.A, object);
057        if (src != null) {
058          writer.writeAttributeFromComponent(HtmlAttributes.HREF, Attributes.SRC);
059          writer.writeTextFromComponent(Attributes.SRC);
060        }
061        writer.endElement(HtmlElements.A);
062        noframes = ResourceManagerUtils.getPropertyNotNull(facesContext, "tobago", "browser.noframe.message.postfix");
063        writer.writeText(" " + noframes);
064    
065        writer.endElement(HtmlElements.IFRAME);
066      }
067    }