1   /**
2    * Copyright (c) 2000-2008 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.ServletRequest;
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   */
37  public class ToggleAreaTag extends ParamAndPropertyAncestorTagImpl {
38  
39      public int doStartTag() throws JspException {
40          try {
41              ServletRequest req = getServletRequest();
42  
43              req.setAttribute("liferay-ui:toggle-area:id", _id);
44              req.setAttribute("liferay-ui:toggle-area:showImage", _showImage);
45              req.setAttribute("liferay-ui:toggle-area:hideImage", _hideImage);
46              req.setAttribute(
47                  "liferay-ui:toggle-area:showMessage", _showMessage);
48              req.setAttribute(
49                  "liferay-ui:toggle-area:hideMessage", _hideMessage);
50              req.setAttribute(
51                  "liferay-ui:toggle-area:defaultShowContent",
52                  String.valueOf(_defaultShowContent));
53              req.setAttribute("liferay-ui:toggle-area:stateVar", _stateVar);
54              req.setAttribute("liferay-ui:toggle-area:align", _align);
55  
56              include(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              include(getEndPage());
68  
69              return EVAL_PAGE;
70          }
71          catch (Exception e) {
72              throw new JspException(e);
73          }
74          finally {
75              _startPage = null;
76              _endPage = null;
77              _id = null;
78              _showMessage = null;
79              _hideMessage = null;
80              _defaultShowContent = true;
81              _stateVar = null;
82              _align = "left";
83          }
84      }
85  
86      public String getStartPage() {
87          if (Validator.isNull(_startPage)) {
88              return _START_PAGE;
89          }
90          else {
91              return _startPage;
92          }
93      }
94  
95      public void setStartPage(String startPage) {
96          _startPage = startPage;
97      }
98  
99      public String getEndPage() {
100         if (Validator.isNull(_endPage)) {
101             return _END_PAGE;
102         }
103         else {
104             return _endPage;
105         }
106     }
107 
108     public void setEndPage(String endPage) {
109         _endPage = endPage;
110     }
111 
112     public void setId(String id) {
113         _id = id;
114     }
115 
116     public void setShowImage(String showImage) {
117         _showImage = showImage;
118     }
119 
120     public void setHideImage(String hideImage) {
121         _hideImage = hideImage;
122     }
123 
124     public void setShowMessage(String showMessage) {
125         _showMessage = showMessage;
126     }
127 
128     public void setHideMessage(String hideMessage) {
129         _hideMessage = hideMessage;
130     }
131 
132     public void setDefaultShowContent(boolean defaultShowContent) {
133         _defaultShowContent = defaultShowContent;
134     }
135 
136     public void setStateVar(String stateVar) {
137         _stateVar = stateVar;
138     }
139 
140     public void setAlign(String align) {
141         _align = align;
142     }
143 
144     private static final String _START_PAGE =
145         "/html/taglib/ui/toggle_area/start.jsp";
146 
147     private static final String _END_PAGE =
148         "/html/taglib/ui/toggle_area/end.jsp";
149 
150     private String _startPage;
151     private String _endPage;
152     private String _id;
153     private String _showImage;
154     private String _hideImage;
155     private String _showMessage;
156     private String _hideMessage;
157     private boolean _defaultShowContent = true;
158     private String _stateVar;
159     private String _align = "left";
160 
161 }