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.util.Validator;
26  import com.liferay.taglib.util.ParamAndPropertyAncestorTagImpl;
27  
28  import javax.servlet.http.HttpServletRequest;
29  import javax.servlet.jsp.JspException;
30  
31  /**
32   * <a href="ToggleAreaTag.java.html"><b><i>View Source</i></b></a>
33   *
34   * @author Raymond Augé
35   */
36  public class ToggleAreaTag extends ParamAndPropertyAncestorTagImpl {
37  
38      public int doStartTag() throws JspException {
39          try {
40              HttpServletRequest request =
41                  (HttpServletRequest)pageContext.getRequest();
42  
43              request.setAttribute("liferay-ui:toggle-area:id", _id);
44              request.setAttribute(
45                  "liferay-ui:toggle-area:showImage", _showImage);
46              request.setAttribute(
47                  "liferay-ui:toggle-area:hideImage", _hideImage);
48              request.setAttribute(
49                  "liferay-ui:toggle-area:showMessage", _showMessage);
50              request.setAttribute(
51                  "liferay-ui:toggle-area:hideMessage", _hideMessage);
52              request.setAttribute(
53                  "liferay-ui:toggle-area:defaultShowContent",
54                  String.valueOf(_defaultShowContent));
55              request.setAttribute("liferay-ui:toggle-area:stateVar", _stateVar);
56              request.setAttribute("liferay-ui:toggle-area:align", _align);
57  
58              include(getStartPage());
59  
60              return EVAL_BODY_INCLUDE;
61          }
62          catch (Exception e) {
63              throw new JspException(e);
64          }
65      }
66  
67      public int doEndTag() throws JspException {
68          try {
69              include(getEndPage());
70  
71              return EVAL_PAGE;
72          }
73          catch (Exception e) {
74              throw new JspException(e);
75          }
76          finally {
77              _startPage = null;
78              _endPage = null;
79              _id = null;
80              _showMessage = null;
81              _hideMessage = null;
82              _defaultShowContent = true;
83              _stateVar = null;
84              _align = "left";
85          }
86      }
87  
88      public String getStartPage() {
89          if (Validator.isNull(_startPage)) {
90              return _START_PAGE;
91          }
92          else {
93              return _startPage;
94          }
95      }
96  
97      public void setStartPage(String startPage) {
98          _startPage = startPage;
99      }
100 
101     public String getEndPage() {
102         if (Validator.isNull(_endPage)) {
103             return _END_PAGE;
104         }
105         else {
106             return _endPage;
107         }
108     }
109 
110     public void setEndPage(String endPage) {
111         _endPage = endPage;
112     }
113 
114     public void setId(String id) {
115         _id = id;
116     }
117 
118     public void setShowImage(String showImage) {
119         _showImage = showImage;
120     }
121 
122     public void setHideImage(String hideImage) {
123         _hideImage = hideImage;
124     }
125 
126     public void setShowMessage(String showMessage) {
127         _showMessage = showMessage;
128     }
129 
130     public void setHideMessage(String hideMessage) {
131         _hideMessage = hideMessage;
132     }
133 
134     public void setDefaultShowContent(boolean defaultShowContent) {
135         _defaultShowContent = defaultShowContent;
136     }
137 
138     public void setStateVar(String stateVar) {
139         _stateVar = stateVar;
140     }
141 
142     public void setAlign(String align) {
143         _align = align;
144     }
145 
146     private static final String _START_PAGE =
147         "/html/taglib/ui/toggle_area/start.jsp";
148 
149     private static final String _END_PAGE =
150         "/html/taglib/ui/toggle_area/end.jsp";
151 
152     private String _startPage;
153     private String _endPage;
154     private String _id;
155     private String _showImage;
156     private String _hideImage;
157     private String _showMessage;
158     private String _hideMessage;
159     private boolean _defaultShowContent = true;
160     private String _stateVar;
161     private String _align = "left";
162 
163 }