1   /**
2    * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
12   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
14   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
15   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
16   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
17   * SOFTWARE.
18   */
19  
20  package com.liferay.taglib.ui;
21  
22  import com.liferay.portal.kernel.dao.search.DisplayTerms;
23  import com.liferay.portal.kernel.servlet.PortalIncludeUtil;
24  import com.liferay.portal.kernel.util.Validator;
25  
26  import javax.servlet.http.HttpServletRequest;
27  import javax.servlet.jsp.JspException;
28  import javax.servlet.jsp.tagext.TagSupport;
29  
30  /**
31   * <a href="SearchToggleTag.java.html"><b><i>View Source</i></b></a>
32   *
33   * @author Brian Wing Shun Chan
34   *
35   */
36  public class SearchToggleTag extends TagSupport {
37  
38      public int doStartTag() throws JspException {
39          try {
40              HttpServletRequest request =
41                  (HttpServletRequest)pageContext.getRequest();
42  
43              request.setAttribute("liferay-ui:search-toggle:id", _id);
44              request.setAttribute(
45                  "liferay-ui:search-toggle:displayTerms", _displayTerms);
46  
47              PortalIncludeUtil.include(pageContext, getStartPage());
48  
49              return EVAL_BODY_INCLUDE;
50          }
51          catch (Exception e) {
52              throw new JspException(e);
53          }
54      }
55  
56      public int doEndTag() throws JspException {
57          try {
58              PortalIncludeUtil.include(pageContext, getEndPage());
59  
60              return EVAL_PAGE;
61          }
62          catch (Exception e) {
63              throw new JspException(e);
64          }
65      }
66  
67      public String getStartPage() {
68          if (Validator.isNull(_startPage)) {
69              return _START_PAGE;
70          }
71          else {
72              return _startPage;
73          }
74      }
75  
76      public void setStartPage(String startPage) {
77          _startPage = startPage;
78      }
79  
80      public String getEndPage() {
81          if (Validator.isNull(_endPage)) {
82              return _END_PAGE;
83          }
84          else {
85              return _endPage;
86          }
87      }
88  
89      public void setEndPage(String endPage) {
90          _endPage = endPage;
91      }
92  
93      public void setId(String id) {
94          _id = id;
95      }
96  
97      public void setDisplayTerms(DisplayTerms displayTerms) {
98          _displayTerms = displayTerms;
99      }
100 
101     private static final String _START_PAGE =
102         "/html/taglib/ui/search_toggle/start.jsp";
103 
104     private static final String _END_PAGE =
105         "/html/taglib/ui/search_toggle/end.jsp";
106 
107     private String _startPage;
108     private String _endPage;
109     private String _id;
110     private DisplayTerms _displayTerms;
111 
112 }