1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * This library is free software; you can redistribute it and/or modify it under
5    * the terms of the GNU Lesser General Public License as published by the Free
6    * Software Foundation; either version 2.1 of the License, or (at your option)
7    * any later version.
8    *
9    * This library is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   * details.
13   */
14  
15  package com.liferay.taglib.ui;
16  
17  import com.liferay.portal.kernel.util.Validator;
18  import com.liferay.taglib.util.ParamAndPropertyAncestorTagImpl;
19  
20  import javax.servlet.http.HttpServletRequest;
21  import javax.servlet.jsp.JspException;
22  
23  /**
24   * <a href="ToggleAreaTag.java.html"><b><i>View Source</i></b></a>
25   *
26   * @author Raymond Augé
27   */
28  public class ToggleAreaTag extends ParamAndPropertyAncestorTagImpl {
29  
30      public int doStartTag() throws JspException {
31          try {
32              HttpServletRequest request =
33                  (HttpServletRequest)pageContext.getRequest();
34  
35              request.setAttribute("liferay-ui:toggle-area:id", _id);
36              request.setAttribute(
37                  "liferay-ui:toggle-area:showImage", _showImage);
38              request.setAttribute(
39                  "liferay-ui:toggle-area:hideImage", _hideImage);
40              request.setAttribute(
41                  "liferay-ui:toggle-area:showMessage", _showMessage);
42              request.setAttribute(
43                  "liferay-ui:toggle-area:hideMessage", _hideMessage);
44              request.setAttribute(
45                  "liferay-ui:toggle-area:defaultShowContent",
46                  String.valueOf(_defaultShowContent));
47              request.setAttribute("liferay-ui:toggle-area:stateVar", _stateVar);
48              request.setAttribute("liferay-ui:toggle-area:align", _align);
49  
50              include(getStartPage());
51  
52              return EVAL_BODY_INCLUDE;
53          }
54          catch (Exception e) {
55              throw new JspException(e);
56          }
57      }
58  
59      public int doEndTag() throws JspException {
60          try {
61              include(getEndPage());
62  
63              return EVAL_PAGE;
64          }
65          catch (Exception e) {
66              throw new JspException(e);
67          }
68          finally {
69              _startPage = null;
70              _endPage = null;
71              _id = null;
72              _showMessage = null;
73              _hideMessage = null;
74              _defaultShowContent = true;
75              _stateVar = null;
76              _align = "left";
77          }
78      }
79  
80      public String getStartPage() {
81          if (Validator.isNull(_startPage)) {
82              return _START_PAGE;
83          }
84          else {
85              return _startPage;
86          }
87      }
88  
89      public void setStartPage(String startPage) {
90          _startPage = startPage;
91      }
92  
93      public String getEndPage() {
94          if (Validator.isNull(_endPage)) {
95              return _END_PAGE;
96          }
97          else {
98              return _endPage;
99          }
100     }
101 
102     public void setEndPage(String endPage) {
103         _endPage = endPage;
104     }
105 
106     public void setId(String id) {
107         _id = id;
108     }
109 
110     public void setShowImage(String showImage) {
111         _showImage = showImage;
112     }
113 
114     public void setHideImage(String hideImage) {
115         _hideImage = hideImage;
116     }
117 
118     public void setShowMessage(String showMessage) {
119         _showMessage = showMessage;
120     }
121 
122     public void setHideMessage(String hideMessage) {
123         _hideMessage = hideMessage;
124     }
125 
126     public void setDefaultShowContent(boolean defaultShowContent) {
127         _defaultShowContent = defaultShowContent;
128     }
129 
130     public void setStateVar(String stateVar) {
131         _stateVar = stateVar;
132     }
133 
134     public void setAlign(String align) {
135         _align = align;
136     }
137 
138     private static final String _START_PAGE =
139         "/html/taglib/ui/toggle_area/start.jsp";
140 
141     private static final String _END_PAGE =
142         "/html/taglib/ui/toggle_area/end.jsp";
143 
144     private String _startPage;
145     private String _endPage;
146     private String _id;
147     private String _showImage;
148     private String _hideImage;
149     private String _showMessage;
150     private String _hideMessage;
151     private boolean _defaultShowContent = true;
152     private String _stateVar;
153     private String _align = "left";
154 
155 }