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.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    }