001    /**
002     * Copyright (c) 2000-2013 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.dao.search.DisplayTerms;
018    import com.liferay.taglib.util.IncludeTag;
019    
020    import javax.servlet.http.HttpServletRequest;
021    
022    /**
023     * @author Brian Wing Shun Chan
024     */
025    public class SearchToggleTag extends IncludeTag {
026    
027            public void setAutoFocus(boolean autoFocus) {
028                    _autoFocus = autoFocus;
029            }
030    
031            public void setButtonLabel(String buttonLabel) {
032                    _buttonLabel = buttonLabel;
033            }
034    
035            public void setDisplayTerms(DisplayTerms displayTerms) {
036                    _displayTerms = displayTerms;
037            }
038    
039            public void setId(String id) {
040                    _id = id;
041            }
042    
043            public void setWidth(String width) {
044                    _width = width;
045            }
046    
047            @Override
048            protected void cleanUp() {
049                    _autoFocus = false;
050                    _buttonLabel = null;
051                    _displayTerms = null;
052                    _id = null;
053            }
054    
055            @Override
056            protected String getEndPage() {
057                    return _END_PAGE;
058            }
059    
060            @Override
061            protected String getStartPage() {
062                    return _START_PAGE;
063            }
064    
065            @Override
066            protected void setAttributes(HttpServletRequest request) {
067                    request.setAttribute(
068                            "liferay-ui:search-toggle:autoFocus", String.valueOf(_autoFocus));
069                    request.setAttribute(
070                            "liferay-ui:search-toggle:buttonLabel", _buttonLabel);
071                    request.setAttribute(
072                            "liferay-ui:search-toggle:displayTerms", _displayTerms);
073                    request.setAttribute("liferay-ui:search-toggle:id", _id);
074                    request.setAttribute("liferay-ui:search-toggle:width", _width);
075            }
076    
077            private static final String _END_PAGE =
078                    "/html/taglib/ui/search_toggle/end.jsp";
079    
080            private static final String _START_PAGE =
081                    "/html/taglib/ui/search_toggle/start.jsp";
082    
083            private boolean _autoFocus;
084            private String _buttonLabel;
085            private DisplayTerms _displayTerms;
086            private String _id;
087            private String _width;
088    
089    }