001    /**
002     * Copyright (c) 2000-2010 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.portlet;
016    
017    import com.liferay.portal.kernel.portlet.LiferayRenderResponse;
018    import com.liferay.portal.theme.PortletDisplay;
019    import com.liferay.portal.theme.ThemeDisplay;
020    import com.liferay.portal.util.WebKeys;
021    
022    import java.util.Collection;
023    
024    import javax.portlet.PortletMode;
025    import javax.portlet.PortletRequest;
026    
027    import javax.servlet.http.HttpServletResponse;
028    
029    /**
030     * @author Brian Wing Shun Chan
031     * @author Eduardo Lundgren
032     */
033    public class RenderResponseImpl
034            extends MimeResponseImpl implements LiferayRenderResponse {
035    
036            public String getLifecycle() {
037                    return PortletRequest.RENDER_PHASE;
038            }
039    
040            public String getResourceName() {
041                    return _resourceName;
042            }
043    
044            public String getTitle() {
045                    return _title;
046            }
047    
048            public Boolean getUseDefaultTemplate() {
049                    return _useDefaultTemplate;
050            }
051    
052            public void setResourceName(String resourceName) {
053                    _resourceName = resourceName;
054            }
055    
056            public void setNextPossiblePortletModes(
057                    Collection<PortletMode> portletModes) {
058            }
059    
060            public void setTitle(String title) {
061                    _title = title;
062    
063                    // See LEP-2188
064    
065                    ThemeDisplay themeDisplay =
066                            (ThemeDisplay)_portletRequestImpl.getAttribute(
067                                    WebKeys.THEME_DISPLAY);
068    
069                    PortletDisplay portletDisplay = themeDisplay.getPortletDisplay();
070    
071                    portletDisplay.setTitle(_title);
072            }
073    
074            public void setUseDefaultTemplate(Boolean useDefaultTemplate) {
075                    _useDefaultTemplate = useDefaultTemplate;
076            }
077    
078            protected void init(
079                    PortletRequestImpl portletRequestImpl, HttpServletResponse response,
080                    String portletName, long companyId, long plid) {
081    
082                    super.init(portletRequestImpl, response, portletName, companyId, plid);
083    
084                    _portletRequestImpl = portletRequestImpl;
085            }
086    
087            private PortletRequestImpl _portletRequestImpl;
088            private String _title;
089            private Boolean _useDefaultTemplate;
090            private String _resourceName;
091    
092    }