/** * Copyright (c) 2000-present Liferay, Inc. All rights reserved. * * This library is free software; you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License as published by the Free * Software Foundation; either version 2.1 of the License, or (at your option) * any later version. * * This library is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more * details. */ package com.liferay.dynamic.data.mapping.form.renderer.internal.servlet.taglib; import com.liferay.portal.kernel.servlet.taglib.BaseDynamicInclude; import com.liferay.portal.kernel.servlet.taglib.DynamicInclude; import com.liferay.portal.kernel.theme.ThemeDisplay; import com.liferay.portal.kernel.util.Portal; import com.liferay.portal.kernel.util.WebKeys; import java.io.IOException; import java.io.PrintWriter; import javax.servlet.ServletContext; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.osgi.service.component.annotations.Activate; import org.osgi.service.component.annotations.Component; import org.osgi.service.component.annotations.Reference; /** * @author Bruno Basto */ @Component(immediate = true, service = DynamicInclude.class) public class DDMFormRendererTopHeadDynamicInclude extends BaseDynamicInclude { @Activate public void activate() { _postfix = _portal.getPathProxy(); if (_postfix.isEmpty()) { _postfix = _servletContext.getContextPath(); } else { _postfix = _postfix.concat(_servletContext.getContextPath()); } _postfix = _postfix.concat( "/css/main.css\" rel=\"stylesheet\" type = \"text/css\" />"); } @Override public void include( HttpServletRequest request, HttpServletResponse response, String key) throws IOException { ThemeDisplay themeDisplay = (ThemeDisplay)request.getAttribute( WebKeys.THEME_DISPLAY); PrintWriter printWriter = response.getWriter(); String content = "<link href=\"".concat(themeDisplay.getPortalURL()); printWriter.println(content.concat(_postfix)); } @Override public void register(DynamicIncludeRegistry dynamicIncludeRegistry) { dynamicIncludeRegistry.register("/html/common/themes/top_head.jsp#pre"); } @Reference private Portal _portal; private String _postfix; @Reference( target = "(osgi.web.symbolicname=com.liferay.dynamic.data.mapping.form.renderer)" ) private ServletContext _servletContext; }