1   /**
2    * Copyright (c) 2000-2010 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   *
12   * 
13   */
14  
15  package com.liferay.taglib.ui;
16  
17  import com.liferay.portal.kernel.dao.search.DisplayTerms;
18  import com.liferay.portal.kernel.servlet.PortalIncludeUtil;
19  import com.liferay.portal.kernel.util.Validator;
20  
21  import javax.servlet.http.HttpServletRequest;
22  import javax.servlet.jsp.JspException;
23  import javax.servlet.jsp.tagext.TagSupport;
24  
25  /**
26   * <a href="SearchToggleTag.java.html"><b><i>View Source</i></b></a>
27   *
28   * @author Brian Wing Shun Chan
29   */
30  public class SearchToggleTag extends TagSupport {
31  
32      public int doStartTag() throws JspException {
33          try {
34              HttpServletRequest request =
35                  (HttpServletRequest)pageContext.getRequest();
36  
37              request.setAttribute("liferay-ui:search-toggle:id", _id);
38              request.setAttribute(
39                  "liferay-ui:search-toggle:displayTerms", _displayTerms);
40  
41              PortalIncludeUtil.include(pageContext, getStartPage());
42  
43              return EVAL_BODY_INCLUDE;
44          }
45          catch (Exception e) {
46              throw new JspException(e);
47          }
48      }
49  
50      public int doEndTag() throws JspException {
51          try {
52              PortalIncludeUtil.include(pageContext, getEndPage());
53  
54              return EVAL_PAGE;
55          }
56          catch (Exception e) {
57              throw new JspException(e);
58          }
59      }
60  
61      public String getStartPage() {
62          if (Validator.isNull(_startPage)) {
63              return _START_PAGE;
64          }
65          else {
66              return _startPage;
67          }
68      }
69  
70      public void setStartPage(String startPage) {
71          _startPage = startPage;
72      }
73  
74      public String getEndPage() {
75          if (Validator.isNull(_endPage)) {
76              return _END_PAGE;
77          }
78          else {
79              return _endPage;
80          }
81      }
82  
83      public void setEndPage(String endPage) {
84          _endPage = endPage;
85      }
86  
87      public void setId(String id) {
88          _id = id;
89      }
90  
91      public void setDisplayTerms(DisplayTerms displayTerms) {
92          _displayTerms = displayTerms;
93      }
94  
95      private static final String _START_PAGE =
96          "/html/taglib/ui/search_toggle/start.jsp";
97  
98      private static final String _END_PAGE =
99          "/html/taglib/ui/search_toggle/end.jsp";
100 
101     private String _startPage;
102     private String _endPage;
103     private String _id;
104     private DisplayTerms _displayTerms;
105 
106 }