001    /**
002     * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
013     */
014    
015    package com.liferay.portal.struts;
016    
017    import javax.servlet.jsp.PageContext;
018    
019    import org.apache.struts.taglib.tiles.ComponentConstants;
020    import org.apache.struts.tiles.ComponentContext;
021    
022    /**
023     * @author Shuyang Zhou
024     */
025    public class TilesAttributeUtil {
026    
027            public static Object getTilesAttribute(
028                    PageContext pageContext, String tilesAttributeName) {
029    
030                    ComponentContext componentContext =
031                            (ComponentContext)pageContext.getAttribute(
032                                    ComponentConstants.COMPONENT_CONTEXT,
033                                    PageContext.REQUEST_SCOPE);
034    
035                    if (componentContext == null) {
036                            return null;
037                    }
038    
039                    return componentContext.getAttribute(tilesAttributeName);
040            }
041    
042            public static void removeComponentContext(PageContext pageContext) {
043                    pageContext.removeAttribute(ComponentConstants.COMPONENT_CONTEXT);
044            }
045    
046    }