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.portal.kernel.dao.search.SearchContainer;
019    import com.liferay.taglib.util.IncludeTag;
020    
021    import java.util.LinkedHashMap;
022    
023    import javax.servlet.http.HttpServletRequest;
024    
025    /**
026     * @author Pei-Jung Lan
027     */
028    public class OrganizationSearchContainerResultsTag<R> extends IncludeTag {
029    
030            public void setOrganizationParams(
031                    LinkedHashMap<String, Object> organizationParams) {
032    
033                    _organizationParams = organizationParams;
034            }
035    
036            public void setParentOrganizationId(long parentOrganizationId) {
037                    _parentOrganizationId = parentOrganizationId;
038            }
039    
040            public void setUseIndexer(boolean useIndexer) {
041                    _useIndexer = useIndexer;
042            }
043    
044            @Override
045            protected void cleanUp() {
046                    _organizationParams = null;
047                    _parentOrganizationId = 0;
048                    _searchTerms = null;
049                    _useIndexer = true;
050            }
051    
052            @Override
053            protected String getPage() {
054                    return _PAGE;
055            }
056    
057            @Override
058            protected void setAttributes(HttpServletRequest request) {
059                    SearchContainerTag<R> searchContainerTag =
060                            (SearchContainerTag<R>)findAncestorWithClass(
061                                    this, SearchContainerTag.class);
062    
063                    SearchContainer<R> searchContainer =
064                            searchContainerTag.getSearchContainer();
065    
066                    _searchTerms = searchContainer.getSearchTerms();
067    
068                    request.setAttribute(
069                            "liferay-ui:organization-search-container-results:useIndexer",
070                            _useIndexer);
071                    request.setAttribute(
072                            "liferay-ui:organization-search-container-results:searchContainer",
073                            searchContainer);
074                    request.setAttribute(
075                            "liferay-ui:organization-search-container-results:searchTerms",
076                            _searchTerms);
077                    request.setAttribute(
078                            "liferay-ui:organization-search-container-results:" +
079                                    "organizationParams",
080                            _organizationParams);
081                    request.setAttribute(
082                            "liferay-ui:organization-search-container-results:" +
083                                    "parentOrganizationId",
084                            _parentOrganizationId);
085            }
086    
087            private static final String _PAGE =
088                    "/html/taglib/ui/organization_search_container_results/page.jsp";
089    
090            private LinkedHashMap<String, Object> _organizationParams;
091            private long _parentOrganizationId;
092            private DisplayTerms _searchTerms;
093            private boolean _useIndexer = true;
094    
095    }