1
19
20 package com.liferay.taglib.ui;
21
22 import com.liferay.portal.kernel.servlet.StringServletResponse;
23 import com.liferay.taglib.util.IncludeTag;
24
25 import java.io.IOException;
26
27 import javax.servlet.RequestDispatcher;
28 import javax.servlet.ServletContext;
29 import javax.servlet.ServletException;
30 import javax.servlet.http.HttpServletRequest;
31 import javax.servlet.http.HttpServletResponse;
32 import javax.servlet.jsp.JspException;
33
34
40 public class PngImageTag extends IncludeTag {
41
42 public static void doTag(
43 String image, String height, String width,
44 ServletContext servletContext, HttpServletRequest request,
45 HttpServletResponse response)
46 throws IOException, ServletException {
47
48 doTag(_PAGE, image, height, width, servletContext, request, response);
49 }
50
51 public static void doTag(
52 String page, String image, String height, String width,
53 ServletContext servletContext, HttpServletRequest request,
54 HttpServletResponse response)
55 throws IOException, ServletException {
56
57 request.setAttribute("liferay-ui:png_image:image", image);
58 request.setAttribute("liferay-ui:png_image:height", height);
59 request.setAttribute("liferay-ui:png_image:width", width);
60
61 RequestDispatcher requestDispatcher =
62 servletContext.getRequestDispatcher(page);
63
64 requestDispatcher.include(request, response);
65 }
66
67 public int doEndTag() throws JspException {
68 try {
69 ServletContext servletContext = getServletContext();
70 HttpServletRequest request = getServletRequest();
71 StringServletResponse response = getServletResponse();
72
73 doTag(
74 getPage(), _image, _height, _width, servletContext, request,
75 response);
76
77 pageContext.getOut().print(response.getString());
78
79 return EVAL_PAGE;
80 }
81 catch (Exception e) {
82 throw new JspException(e);
83 }
84 }
85
86 public void setImage(String image) {
87 _image = image;
88 }
89
90 public void setHeight(String height) {
91 _height = height;
92 }
93
94 public void setWidth(String width) {
95 _width = width;
96 }
97
98 protected String getDefaultPage() {
99 return _PAGE;
100 }
101
102 private static final String _PAGE = "/html/taglib/ui/png_image/page.jsp";
103
104 private String _image;
105 private String _height;
106 private String _width;
107
108 }