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