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.theme;
16  
17  import com.liferay.portal.model.Layout;
18  
19  import javax.servlet.RequestDispatcher;
20  import javax.servlet.ServletContext;
21  import javax.servlet.http.HttpServletRequest;
22  import javax.servlet.http.HttpServletResponse;
23  
24  /**
25   * <a href="LayoutIconTag.java.html"><b><i>View Source</i></b></a>
26   *
27   * @author Brian Wing Shun Chan
28   */
29  public class LayoutIconTag extends com.liferay.taglib.util.IncludeTag {
30  
31      public static void doTag(
32              Layout layout, ServletContext servletContext,
33              HttpServletRequest request, HttpServletResponse response)
34          throws Exception {
35  
36          doTag(_PAGE, layout, servletContext, request, response);
37      }
38  
39      public static void doTag(
40              String page, Layout layout, ServletContext servletContext,
41              HttpServletRequest request, HttpServletResponse response)
42          throws Exception {
43  
44          setRequestAttributes(request, layout);
45  
46          RequestDispatcher requestDispatcher =
47              servletContext.getRequestDispatcher(page);
48  
49          requestDispatcher.include(request, response);
50      }
51  
52      public static void setRequestAttributes(
53          HttpServletRequest request, Layout layout) {
54  
55          request.setAttribute("liferay-theme:layout-icon:layout", layout);
56      }
57  
58      public int doStartTag() {
59          HttpServletRequest request =
60              (HttpServletRequest)pageContext.getRequest();
61  
62          setRequestAttributes(request, _layout);
63  
64          return EVAL_BODY_BUFFERED;
65      }
66  
67      public void setLayout(Layout layout) {
68          _layout = layout;
69      }
70  
71      public String getDefaultPage() {
72          return _PAGE;
73      }
74  
75      private static final String _PAGE =
76          "/html/taglib/theme/layout_icon/page.jsp";
77  
78      private Layout _layout;
79  
80  }