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
45 public class BreadcrumbTag extends IncludeTag {
46
47 public static void doTag(
48 ServletContext servletContext, HttpServletRequest request,
49 HttpServletResponse response)
50 throws IOException, ServletException {
51
52 doTag(
53 _PAGE, null, null, null, _DISPLAY_STYLE, servletContext, request,
54 response);
55 }
56
57 public static void doTag(
58 String page, Layout selLayout, String selLayoutParam,
59 PortletURL portletURL, int displayStyle,
60 ServletContext servletContext, HttpServletRequest request,
61 HttpServletResponse response)
62 throws IOException, ServletException {
63
64 request.setAttribute(
65 "liferay-ui:breadcrumb:displayStyle", String.valueOf(displayStyle));
66 request.setAttribute("liferay-ui:breadcrumb:selLayout", selLayout);
67 request.setAttribute(
68 "liferay-ui:breadcrumb:selLayoutParam", selLayoutParam);
69 request.setAttribute("liferay-ui:breadcrumb:portletURL", portletURL);
70
71 RequestDispatcher requestDispatcher =
72 servletContext.getRequestDispatcher(page);
73
74 requestDispatcher.include(request, response);
75 }
76
77 public int doEndTag() throws JspException {
78 try {
79 ServletContext servletContext = getServletContext();
80 HttpServletRequest request = getServletRequest();
81 StringServletResponse stringResponse = getServletResponse();
82
83 doTag(
84 getPage(), _selLayout, _selLayoutParam, _portletURL,
85 _displayStyle, servletContext, request, stringResponse);
86
87 pageContext.getOut().print(stringResponse.getString());
88
89 return EVAL_PAGE;
90 }
91 catch (Exception e) {
92 throw new JspException(e);
93 }
94 }
95
96 public void setDisplayStyle(int displayStyle) {
97 _displayStyle = displayStyle;
98 }
99
100 public void setPortletURL(PortletURL portletURL) {
101 _portletURL = portletURL;
102 }
103
104 public void setSelLayout(Layout selLayout) {
105 _selLayout = selLayout;
106 }
107
108 public void setSelLayoutParam(String selLayoutParam) {
109 _selLayoutParam = selLayoutParam;
110 }
111
112 protected String getDefaultPage() {
113 return _PAGE;
114 }
115
116 private static final int _DISPLAY_STYLE = 0;
117
118 private static final String _PAGE = "/html/taglib/ui/breadcrumb/page.jsp";
119
120 private int _displayStyle = _DISPLAY_STYLE;
121 private PortletURL _portletURL;
122 private Layout _selLayout;
123 private String _selLayoutParam;
124
125 }