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.util;
16  
17  import com.liferay.portal.kernel.util.StringBundler;
18  import com.liferay.portal.kernel.util.StringPool;
19  import com.liferay.portal.kernel.util.WebKeys;
20  
21  import javax.servlet.http.HttpServletRequest;
22  import javax.servlet.jsp.tagext.BodyTagSupport;
23  
24  /**
25   * <a href="HtmlBottomTag.java.html"><b><i>View Source</i></b></a>
26   *
27   * @author Brian Wing Shun Chan
28   */
29  public class HtmlBottomTag extends BodyTagSupport {
30  
31      public int doStartTag() {
32          return EVAL_BODY_BUFFERED;
33      }
34  
35      public int doAfterBody() {
36          _bodyContentString = getBodyContent().getString();
37  
38          return SKIP_BODY;
39      }
40  
41      public int doEndTag() {
42          HttpServletRequest request =
43              (HttpServletRequest)pageContext.getRequest();
44  
45          StringBundler sb = (StringBundler)request.getAttribute(
46              WebKeys.PAGE_BOTTOM);
47  
48          if (sb == null) {
49              sb = new StringBundler();
50  
51              request.setAttribute(WebKeys.PAGE_BOTTOM, sb);
52          }
53  
54          sb.append(_bodyContentString);
55  
56          return EVAL_PAGE;
57      }
58  
59      private String _bodyContentString = StringPool.BLANK;
60  
61  }