/**
* 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.portal.struts;
import com.liferay.portal.kernel.servlet.taglib.BaseDynamicInclude;
import com.liferay.portal.kernel.theme.ThemeDisplay;
import com.liferay.portal.kernel.util.GetterUtil;
import com.liferay.portal.kernel.util.WebKeys;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.tiles.ComponentContext;
import org.apache.struts.tiles.taglib.ComponentConstants;
import org.osgi.service.component.annotations.Component;
/**
* @author Raymond Augé
*/
@Component
public class DoIncludeJSPDynamicInclude extends BaseDynamicInclude {
@Override
public void include(
HttpServletRequest request, HttpServletResponse response, String key) {
ThemeDisplay themeDisplay = (ThemeDisplay)request.getAttribute(
WebKeys.THEME_DISPLAY);
ComponentContext componentContext =
(ComponentContext)request.getAttribute(
ComponentConstants.COMPONENT_CONTEXT);
if (componentContext == null) {
themeDisplay.setTilesSelectable(true);
}
String tilesContent = (String)componentContext.getAttribute("content");
themeDisplay.setTilesContent(tilesContent);
boolean tilesSelectable = GetterUtil.getBoolean(
(String)componentContext.getAttribute("selectable"));
themeDisplay.setTilesSelectable(tilesSelectable);
String tilesTitle = (String)componentContext.getAttribute("title");
themeDisplay.setTilesTitle(tilesTitle);
}
@Override
public void register(DynamicIncludeRegistry dynamicIncludeRegistry) {
dynamicIncludeRegistry.register(
"com.liferay.taglib.util.ThemeUtil#doIncludeJS");
}
}