001    /**
002     * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.struts;
016    
017    import com.liferay.portal.kernel.servlet.taglib.BaseDynamicInclude;
018    import com.liferay.portal.kernel.spring.osgi.OSGiBeanProperties;
019    import com.liferay.portal.kernel.util.GetterUtil;
020    import com.liferay.portal.kernel.util.WebKeys;
021    import com.liferay.portal.theme.ThemeDisplay;
022    
023    import javax.servlet.http.HttpServletRequest;
024    import javax.servlet.http.HttpServletResponse;
025    
026    import org.apache.struts.taglib.tiles.ComponentConstants;
027    import org.apache.struts.tiles.ComponentContext;
028    
029    /**
030     * @author Raymond Aug??
031     */
032    @OSGiBeanProperties(
033            property = {"key=com.liferay.taglib.util.ThemeUtil#doIncludeJSP"}
034    )
035    public class DoIncludeJSPDynamicInclude extends BaseDynamicInclude {
036    
037            @Override
038            public void include(
039                    HttpServletRequest request, HttpServletResponse response, String key) {
040    
041                    ComponentContext componentContext =
042                            (ComponentContext)request.getAttribute(
043                                    ComponentConstants.COMPONENT_CONTEXT);
044    
045                    if (componentContext == null) {
046                            return;
047                    }
048    
049                    ThemeDisplay themeDisplay = (ThemeDisplay)request.getAttribute(
050                            WebKeys.THEME_DISPLAY);
051    
052                    String tilesContent = (String)componentContext.getAttribute("content");
053    
054                    themeDisplay.setTilesContent(tilesContent);
055    
056                    boolean tilesSelectable = GetterUtil.getBoolean(
057                            (String)componentContext.getAttribute("selectable"));
058    
059                    themeDisplay.setTilesSelectable(tilesSelectable);
060    
061                    String tilesTitle = (String)componentContext.getAttribute("title");
062    
063                    themeDisplay.setTilesTitle(tilesTitle);
064            }
065    
066    }