1
22
23 package com.liferay.taglib.ui;
24
25 import com.liferay.portal.kernel.servlet.StringServletResponse;
26 import com.liferay.portal.model.Layout;
27 import com.liferay.taglib.util.IncludeTag;
28
29 import java.io.IOException;
30
31 import javax.portlet.PortletURL;
32
33 import javax.servlet.RequestDispatcher;
34 import javax.servlet.ServletContext;
35 import javax.servlet.ServletException;
36 import javax.servlet.http.HttpServletRequest;
37 import javax.servlet.http.HttpServletResponse;
38 import javax.servlet.jsp.JspException;
39
40
46 public class BreadcrumbTag extends IncludeTag {
47
48 public static void doTag(
49 ServletContext servletContext, HttpServletRequest request,
50 HttpServletResponse response)
51 throws IOException, ServletException {
52
53 doTag(
54 _PAGE, null, null, null, _DISPLAY_STYLE, servletContext, request,
55 response);
56 }
57
58 public static void doTag(
59 String page, Layout selLayout, String selLayoutParam,
60 PortletURL portletURL, int displayStyle,
61 ServletContext servletContext, HttpServletRequest request,
62 HttpServletResponse response)
63 throws IOException, ServletException {
64
65 request.setAttribute("liferay-ui:breadcrumb:selLayout", selLayout);
66 request.setAttribute(
67 "liferay-ui:breadcrumb:selLayoutParam", selLayoutParam);
68 request.setAttribute("liferay-ui:breadcrumb:portletURL", portletURL);
69 request.setAttribute(
70 "liferay-ui:breadcrumb:displayStyle", String.valueOf(displayStyle));
71
72 RequestDispatcher requestDispatcher =
73 servletContext.getRequestDispatcher(page);
74
75 requestDispatcher.include(request, response);
76 }
77
78 public int doEndTag() throws JspException {
79 try {
80 ServletContext servletContext = getServletContext();
81 HttpServletRequest request = getServletRequest();
82 StringServletResponse stringResponse = getServletResponse();
83
84 doTag(
85 getPage(), _selLayout, _selLayoutParam, _portletURL,
86 _displayStyle, servletContext, request, stringResponse);
87
88 pageContext.getOut().print(stringResponse.getString());
89
90 return EVAL_PAGE;
91 }
92 catch (Exception e) {
93 throw new JspException(e);
94 }
95 }
96
97 public void setSelLayout(Layout selLayout) {
98 _selLayout = selLayout;
99 }
100
101 public void setSelLayoutParam(String selLayoutParam) {
102 _selLayoutParam = selLayoutParam;
103 }
104
105 public void setPortletURL(PortletURL portletURL) {
106 _portletURL = portletURL;
107 }
108
109 public void setDisplayStyle(int displayStyle) {
110 _displayStyle = displayStyle;
111 }
112
113 protected String getDefaultPage() {
114 return _PAGE;
115 }
116
117 private static final String _PAGE = "/html/taglib/ui/breadcrumb/page.jsp";
118
119 private static final int _DISPLAY_STYLE = 0;
120
121 private Layout _selLayout;
122 private String _selLayoutParam;
123 private PortletURL _portletURL;
124 private int _displayStyle = _DISPLAY_STYLE;
125
126 }