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="UserSearchTag.java.html"><b><i>View Source</i></b></a>
39   *
40   * @author Brian Wing Shun Chan
41   *
42   */
43  public class UserSearchTag extends TagSupport {
44  
45      public int doStartTag() throws JspException {
46          try {
47              HttpServletRequest request =
48                  (HttpServletRequest)pageContext.getRequest();
49  
50              request.setAttribute(
51                  "liferay-ui:user-search:portletURL", _portletURL);
52              request.setAttribute(
53                  "liferay-ui:user-search:rowChecker", _rowChecker);
54              request.setAttribute(
55                  "liferay-ui:user-search:userParams", _userParams);
56  
57              PortalIncludeUtil.include(pageContext, getStartPage());
58  
59              return EVAL_BODY_INCLUDE;
60          }
61          catch (Exception e) {
62              throw new JspException(e);
63          }
64      }
65  
66      public int doEndTag() throws JspException {
67          try {
68              PortalIncludeUtil.include(pageContext, getEndPage());
69  
70              return EVAL_PAGE;
71          }
72          catch (Exception e) {
73              throw new JspException(e);
74          }
75      }
76  
77      public String getStartPage() {
78          if (Validator.isNull(_startPage)) {
79              return _START_PAGE;
80          }
81          else {
82              return _startPage;
83          }
84      }
85  
86      public void setStartPage(String startPage) {
87          _startPage = startPage;
88      }
89  
90      public String getEndPage() {
91          if (Validator.isNull(_endPage)) {
92              return _END_PAGE;
93          }
94          else {
95              return _endPage;
96          }
97      }
98  
99      public void setEndPage(String endPage) {
100         _endPage = endPage;
101     }
102 
103     public void setPortletURL(PortletURL portletURL) {
104         _portletURL = portletURL;
105     }
106 
107     public void setRowChecker(RowChecker rowChecker) {
108         _rowChecker = rowChecker;
109     }
110 
111     public void setUserParams(LinkedHashMap<String, Object> userParams) {
112         _userParams = userParams;
113     }
114 
115     private static final String _START_PAGE =
116         "/html/taglib/ui/user_search/start.jsp";
117 
118     private static final String _END_PAGE =
119         "/html/taglib/ui/user_search/end.jsp";
120 
121     private String _startPage;
122     private String _endPage;
123     private PortletURL _portletURL;
124     private RowChecker _rowChecker;
125     private LinkedHashMap<String, Object> _userParams;
126 
127 }