001    /**
002     * Copyright (c) 2000-2011 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.taglib.ui;
016    
017    import com.liferay.portal.kernel.util.ParamUtil;
018    import com.liferay.portal.kernel.util.Validator;
019    import com.liferay.taglib.util.IncludeTag;
020    
021    import javax.servlet.http.HttpServletRequest;
022    
023    /**
024     * @author Sergio González
025     */
026    public class HeaderTag extends IncludeTag {
027    
028            @Override
029            protected void setAttributes(HttpServletRequest request) {
030                    request.setAttribute("liferay-ui:header:backLabel", _backLabel);
031    
032                    String redirect = ParamUtil.getString(request, "redirect");
033    
034                    if (Validator.isNull(_backURL) && Validator.isNotNull(redirect)) {
035                            request.setAttribute("liferay-ui:header:backURL", redirect);
036                    }
037                    else {
038                            request.setAttribute("liferay-ui:header:backURL", _backURL);
039                    }
040    
041                    request.setAttribute("liferay-ui:header:cssClass", _cssClass);
042                    request.setAttribute(
043                            "liferay-ui:header:escapeXml", String.valueOf(_escapeXml));
044                    request.setAttribute(
045                            "liferay-ui:header:localizeTitle", String.valueOf(_localizeTitle));
046                    request.setAttribute(
047                            "liferay-ui:header:showBackURL", String.valueOf(_showBackURL));
048                    request.setAttribute("liferay-ui:header:title", _title);
049            }
050    
051            @Override
052            protected void cleanUp() {
053                    _backLabel = null;
054                    _backURL = null;
055                    _cssClass = null;
056                    _escapeXml = true;
057                    _localizeTitle = true;
058                    _showBackURL = true;
059                    _title = null;
060            }
061    
062            @Override
063            protected String getPage() {
064                    return _PAGE;
065            }
066    
067            @Override
068            protected boolean isCleanUpSetAttributes() {
069                    return _CLEAN_UP_SET_ATTRIBUTES;
070            }
071    
072            public void setBackLabel(String backLabel) {
073                    _backLabel = backLabel;
074            }
075    
076            public void setBackURL(String backURL) {
077                    _backURL = backURL;
078            }
079    
080            public void setCssClass(String cssClass) {
081                    _cssClass = cssClass;
082            }
083    
084            public void setEscapeXml(boolean escapeXml) {
085                    _escapeXml = escapeXml;
086            }
087    
088            public void setLocalizeTitle(boolean localizeTitle) {
089                    _localizeTitle = localizeTitle;
090            }
091    
092            public void setShowBackURL(boolean showBackURL) {
093                    _showBackURL = showBackURL;
094            }
095    
096            public void setTitle(String title) {
097                    _title = title;
098            }
099    
100            private static final boolean _CLEAN_UP_SET_ATTRIBUTES = true;
101    
102            private static final String _PAGE = "/html/taglib/ui/header/page.jsp";
103    
104            private String _backLabel;
105            private String _backURL;
106            private String _cssClass;
107            private boolean _escapeXml = true;
108            private boolean _localizeTitle = true;
109            private boolean _showBackURL = true;
110            private String _title;
111    
112    }