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.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            @Override
044            protected void cleanUp() {
045                    _autoFocus = false;
046                    _buttonLabel = null;
047                    _displayTerms = null;
048                    _id = null;
049            }
050    
051            @Override
052            protected String getEndPage() {
053                    return _END_PAGE;
054            }
055    
056            @Override
057            protected String getStartPage() {
058                    return _START_PAGE;
059            }
060    
061            @Override
062            protected void setAttributes(HttpServletRequest request) {
063                    request.setAttribute(
064                            "liferay-ui:search-toggle:autoFocus", String.valueOf(_autoFocus));
065                    request.setAttribute(
066                            "liferay-ui:search-toggle:buttonLabel", _buttonLabel);
067                    request.setAttribute(
068                            "liferay-ui:search-toggle:displayTerms", _displayTerms);
069                    request.setAttribute("liferay-ui:search-toggle:id", _id);
070            }
071    
072            private static final String _END_PAGE =
073                    "/html/taglib/ui/search_toggle/end.jsp";
074    
075            private static final String _START_PAGE =
076                    "/html/taglib/ui/search_toggle/start.jsp";
077    
078            private boolean _autoFocus;
079            private String _buttonLabel;
080            private DisplayTerms _displayTerms;
081            private String _id;
082    
083    }