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.servlet.PortalIncludeUtil;
18  import com.liferay.portal.kernel.util.StringPool;
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.BodyContent;
24  import javax.servlet.jsp.tagext.BodyTagSupport;
25  
26  /**
27   * <a href="PanelTag.java.html"><b><i>View Source</i></b></a>
28   *
29   * @author Brian Wing Shun Chan
30   */
31  public class PanelTag extends BodyTagSupport {
32  
33      public int doStartTag() {
34          HttpServletRequest request =
35              (HttpServletRequest)pageContext.getRequest();
36  
37          request.setAttribute("liferay-ui:panel:id", _id);
38          request.setAttribute("liferay-ui:panel:title", _title);
39          request.setAttribute(
40              "liferay-ui:panel:collapsible", String.valueOf(_collapsible));
41          request.setAttribute("liferay-ui:panel:defaultState", _defaultState);
42          request.setAttribute(
43              "liferay-ui:panel:persistState", String.valueOf(_persistState));
44          request.setAttribute(
45              "liferay-ui:panel:extended", String.valueOf(_extended));
46          request.setAttribute("liferay-ui:panel:cssClass", _cssClass);
47  
48          return EVAL_BODY_BUFFERED;
49      }
50  
51      public int doAfterBody() {
52          BodyContent bodyContent = getBodyContent();
53  
54          _bodyContentString = bodyContent.getString();
55  
56          return SKIP_BODY;
57      }
58  
59      public int doEndTag() throws JspException {
60          try {
61              PortalIncludeUtil.include(pageContext, getStartPage());
62  
63              pageContext.getOut().print(_bodyContentString);
64  
65              PortalIncludeUtil.include(pageContext, getEndPage());
66  
67              return EVAL_PAGE;
68          }
69          catch (Exception e) {
70              throw new JspException(e);
71          }
72      }
73  
74      public String getStartPage() {
75          if (Validator.isNull(_startPage)) {
76              return _START_PAGE;
77          }
78          else {
79              return _startPage;
80          }
81      }
82  
83      public void setStartPage(String startPage) {
84          _startPage = startPage;
85      }
86  
87      public String getEndPage() {
88          if (Validator.isNull(_endPage)) {
89              return _END_PAGE;
90          }
91          else {
92              return _endPage;
93          }
94      }
95  
96      public void setEndPage(String endPage) {
97          _endPage = endPage;
98      }
99  
100     public void setId(String id) {
101         _id = id;
102     }
103 
104     public void setTitle(String title) {
105         _title = title;
106     }
107 
108     public void setCollapsible(boolean collapsible) {
109         _collapsible = collapsible;
110     }
111 
112     public void setDefaultState(String defaultState) {
113         _defaultState = defaultState;
114     }
115 
116     public void setPersistState(boolean persistState) {
117         _persistState = persistState;
118     }
119 
120     public void setExtended(boolean extended) {
121         _extended = extended;
122     }
123 
124     public void setCssClass(String cssClass) {
125         _cssClass = cssClass;
126     }
127 
128     private static final String _START_PAGE = "/html/taglib/ui/panel/start.jsp";
129 
130     private static final String _END_PAGE = "/html/taglib/ui/panel/end.jsp";
131 
132     private String _startPage;
133     private String _endPage;
134     private String _id;
135     private String _title;
136     private boolean _collapsible = true;
137     private String _defaultState = "open";
138     private boolean _persistState = true;
139     private boolean _extended;
140     private String _cssClass = StringPool.BLANK;
141     private String _bodyContentString = StringPool.BLANK;
142 
143 }