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.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  }