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