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            @Override
041            protected void cleanUp() {
042                    _organizationParams = null;
043                    _parentOrganizationId = 0;
044                    _searchTerms = null;
045            }
046    
047            @Override
048            protected String getPage() {
049                    return _PAGE;
050            }
051    
052            @Override
053            protected void setAttributes(HttpServletRequest request) {
054                    SearchContainerTag<R> searchContainerTag =
055                            (SearchContainerTag<R>)findAncestorWithClass(
056                                    this, SearchContainerTag.class);
057    
058                    SearchContainer<R> searchContainer =
059                            searchContainerTag.getSearchContainer();
060    
061                    _searchTerms = searchContainer.getSearchTerms();
062    
063                    request.setAttribute(
064                            "liferay-ui:organization-search-container-results:searchContainer",
065                            searchContainer);
066                    request.setAttribute(
067                            "liferay-ui:organization-search-container-results:searchTerms",
068                            _searchTerms);
069                    request.setAttribute(
070                            "liferay-ui:organization-search-container-results:" +
071                                    "organizationParams",
072                            _organizationParams);
073                    request.setAttribute(
074                            "liferay-ui:organization-search-container-results:" +
075                                    "parentOrganizationId",
076                            _parentOrganizationId);
077            }
078    
079            private static final String _PAGE =
080                    "/html/taglib/ui/organization_search_container_results/page.jsp";
081    
082            private LinkedHashMap<String, Object> _organizationParams;
083            private long _parentOrganizationId;
084            private DisplayTerms _searchTerms;
085    
086    }