1
14
15 package com.liferay.taglib.portletext;
16
17 import com.liferay.portal.kernel.servlet.PipingServletResponse;
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
31 public class PreviewTag extends IncludeTag {
32
33 public static void doTag(
34 String portletName, String queryString, String width,
35 ServletContext servletContext, HttpServletRequest request,
36 HttpServletResponse response)
37 throws Exception {
38
39 doTag(
40 _PAGE, portletName, queryString, width, servletContext, request,
41 response);
42 }
43
44 public static void doTag(
45 String page, String portletName, String queryString, String width,
46 ServletContext servletContext, HttpServletRequest request,
47 HttpServletResponse response)
48 throws Exception {
49
50 request.setAttribute(
51 "liferay-portlet:preview:portletName", portletName);
52 request.setAttribute(
53 "liferay-portlet:preview:queryString", queryString);
54 request.setAttribute("liferay-portlet:preview:width", width);
55
56 RequestDispatcher requestDispatcher =
57 servletContext.getRequestDispatcher(page);
58
59 requestDispatcher.include(request, response);
60 }
61
62 public int doEndTag() throws JspException {
63 try {
64 ServletContext servletContext = getServletContext();
65 HttpServletRequest request = getServletRequest();
66
67 doTag(
68 getPage(), _portletName, _queryString, _width, servletContext,
69 request, new PipingServletResponse(pageContext));
70
71 return EVAL_PAGE;
72 }
73 catch (Exception e) {
74 throw new JspException(e);
75 }
76 }
77
78 public void setPortletName(String portletName) {
79 _portletName = portletName;
80 }
81
82 public void setQueryString(String queryString) {
83 _queryString = queryString;
84 }
85
86 public void setWidth(String width) {
87 _width = width;
88 }
89
90 protected String getPage() {
91 return _PAGE;
92 }
93
94 private static final String _PAGE = "/html/taglib/portlet/preview/page.jsp";
95
96 private String _portletName;
97 private String _queryString;
98 private String _width;
99
100 }