001/* 002 * (C) Copyright 2015 Nuxeo SA (http://nuxeo.com/) and contributors. 003 * 004 * All rights reserved. This program and the accompanying materials 005 * are made available under the terms of the GNU Lesser General Public License 006 * (LGPL) version 2.1 which accompanies this distribution, and is available at 007 * http://www.gnu.org/licenses/lgpl-2.1.html 008 * 009 * This library is distributed in the hope that it will be useful, 010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 012 * Lesser General Public License for more details. 013 * 014 * Contributors: 015 * Anahide Tchertchian 016 */ 017package org.nuxeo.ecm.web.resources.jsf; 018 019import java.io.IOException; 020 021import javax.faces.component.UIComponent; 022import javax.faces.context.FacesContext; 023import javax.faces.context.ResponseWriter; 024 025/** 026 * Renderer for HTML imports. 027 * 028 * @since 6.0 029 */ 030public class HTMLImportRenderer extends AbstractResourceRenderer { 031 032 @Override 033 public void encodeEnd(FacesContext context, UIComponent component) throws IOException { 034 String url = resolveUrl(context, component); 035 if (url != null) { 036 ResponseWriter writer = context.getResponseWriter(); 037 startElement(writer, component); 038 writer.writeURIAttribute("href", url, "href"); 039 endElement(writer); 040 } 041 } 042 043 @Override 044 protected void startElement(ResponseWriter writer, UIComponent component) throws IOException { 045 writer.startElement("link", component); 046 writer.writeAttribute("rel", "import", "rel"); 047 } 048 049 @Override 050 protected void endElement(ResponseWriter writer) throws IOException { 051 writer.endElement("link"); 052 } 053 054}