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