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.StringServletResponse;
18  import com.liferay.taglib.util.IncludeTag;
19  
20  import javax.servlet.RequestDispatcher;
21  import javax.servlet.ServletContext;
22  import javax.servlet.http.HttpServletRequest;
23  import javax.servlet.http.HttpServletResponse;
24  import javax.servlet.jsp.JspException;
25  
26  /**
27   * <a href="StagingTag.java.html"><b><i>View Source</i></b></a>
28   *
29   * @author Brian Wing Shun Chan
30   */
31  public class StagingTag extends IncludeTag {
32  
33      public static void doTag(
34              ServletContext servletContext, HttpServletRequest request,
35              HttpServletResponse response)
36          throws Exception {
37  
38          doTag(_PAGE, servletContext, request, response);
39      }
40  
41      public static void doTag(
42              String page, ServletContext servletContext,
43              HttpServletRequest request, HttpServletResponse response)
44          throws Exception {
45  
46          RequestDispatcher requestDispatcher =
47              servletContext.getRequestDispatcher(page);
48  
49          requestDispatcher.include(request, response);
50      }
51  
52      public int doEndTag() throws JspException {
53          try {
54              ServletContext servletContext = getServletContext();
55              HttpServletRequest request = getServletRequest();
56              StringServletResponse response = getServletResponse();
57  
58              doTag(getPage(), servletContext, request, response);
59  
60              pageContext.getOut().print(response.getString());
61  
62              return EVAL_PAGE;
63          }
64          catch (Exception e) {
65              throw new JspException(e);
66          }
67      }
68  
69      protected String getDefaultPage() {
70          return _PAGE;
71      }
72  
73      private static final String _PAGE = "/html/taglib/ui/staging/page.jsp";
74  
75  }