1   /**
2    * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved.
3    *
4    * Permission is hereby granted, free of charge, to any person obtaining a copy
5    * of this software and associated documentation files (the "Software"), to deal
6    * in the Software without restriction, including without limitation the rights
7    * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8    * copies of the Software, and to permit persons to whom the Software is
9    * furnished to do so, subject to the following conditions:
10   *
11   * The above copyright notice and this permission notice shall be included in
12   * all copies or substantial portions of the Software.
13   *
14   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20   * SOFTWARE.
21   */
22  
23  package com.liferay.taglib.ui;
24  
25  import com.liferay.portal.kernel.dao.search.RowChecker;
26  import com.liferay.portal.kernel.servlet.PortalIncludeUtil;
27  import com.liferay.portal.kernel.util.Validator;
28  
29  import java.util.LinkedHashMap;
30  
31  import javax.portlet.PortletURL;
32  
33  import javax.servlet.http.HttpServletRequest;
34  import javax.servlet.jsp.JspException;
35  import javax.servlet.jsp.tagext.TagSupport;
36  
37  /**
38   * <a href="GroupSearchTag.java.html"><b><i>View Source</i></b></a>
39   *
40   * @author Brian Wing Shun Chan
41   */
42  public class GroupSearchTag extends TagSupport {
43  
44      public int doEndTag() throws JspException {
45          try {
46              PortalIncludeUtil.include(pageContext, getEndPage());
47  
48              return EVAL_PAGE;
49          }
50          catch (Exception e) {
51              throw new JspException(e);
52          }
53      }
54  
55      public int doStartTag() throws JspException {
56          try {
57              HttpServletRequest request =
58                  (HttpServletRequest)pageContext.getRequest();
59  
60              request.setAttribute(
61                  "liferay-ui:group-search:groupParams", _groupParams);
62              request.setAttribute(
63                  "liferay-ui:group-search:portletURL", _portletURL);
64              request.setAttribute(
65                  "liferay-ui:group-search:rowChecker", _rowChecker);
66  
67              PortalIncludeUtil.include(pageContext, getStartPage());
68  
69              return EVAL_BODY_INCLUDE;
70          }
71          catch (Exception e) {
72              throw new JspException(e);
73          }
74      }
75  
76      public String getEndPage() {
77          if (Validator.isNull(_endPage)) {
78              return _END_PAGE;
79          }
80          else {
81              return _endPage;
82          }
83      }
84  
85      public String getStartPage() {
86          if (Validator.isNull(_startPage)) {
87              return _START_PAGE;
88          }
89          else {
90              return _startPage;
91          }
92      }
93  
94      public void setEndPage(String endPage) {
95          _endPage = endPage;
96      }
97  
98      public void setGroupParams(LinkedHashMap<String, Object> groupParams) {
99          _groupParams = groupParams;
100     }
101 
102     public void setPortletURL(PortletURL portletURL) {
103         _portletURL = portletURL;
104     }
105 
106     public void setRowChecker(RowChecker rowChecker) {
107         _rowChecker = rowChecker;
108     }
109 
110     public void setStartPage(String startPage) {
111         _startPage = startPage;
112     }
113 
114     private static final String _END_PAGE =
115         "/html/taglib/ui/group_search/end.jsp";
116 
117     private static final String _START_PAGE =
118         "/html/taglib/ui/group_search/start.jsp";
119 
120     private String _endPage;
121     private LinkedHashMap<String, Object> _groupParams;
122     private PortletURL _portletURL;
123     private RowChecker _rowChecker;
124     private String _startPage;
125 
126 }