001    /**
002     * Copyright (c) 2000-2010 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.taglib.ui;
016    
017    import com.liferay.portal.kernel.dao.search.SearchContainer;
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 SearchFormTag extends IncludeTag {
026    
027            public void setSearchContainer(SearchContainer<?> searchContainer) {
028                    _searchContainer = searchContainer;
029            }
030    
031            public void setShowAddButton(boolean showAddButton) {
032                    _showAddButton = showAddButton;
033            }
034    
035            protected void cleanUp() {
036                    _searchContainer = null;
037                    _showAddButton = false;
038            }
039    
040            protected void setAttributes(HttpServletRequest request) {
041                    SearchContainerTag parentTag =
042                            (SearchContainerTag)findAncestorWithClass(
043                                    this, SearchContainerTag.class);
044    
045                    if (parentTag != null) {
046                            _searchContainer = parentTag.getSearchContainer();
047                    }
048    
049                    request.setAttribute(
050                            "liferay-ui:search:searchContainer", _searchContainer);
051                    request.setAttribute(
052                            "liferay-ui:search:showAddButton", String.valueOf(_showAddButton));
053            }
054    
055            private SearchContainer<?> _searchContainer;
056            private boolean _showAddButton;
057    
058    }