1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.apache.portals.bridges.struts.taglib;
17
18 import javax.servlet.ServletRequest;
19 import javax.servlet.jsp.JspException;
20
21 import org.apache.portals.bridges.struts.PortletServlet;
22
23 /***
24 * Supports the Struts html:image tag to be used within a Portlet context allowing relative
25 * img src paths.
26 *
27 * @author <a href="mailto:ate@douma.nu">Ate Douma</a>
28 * @version $Id: ImageTag.java 188222 2005-01-20 02:41:15 +0100 (Thu, 20 Jan 2005) ate $
29 */
30 public class ImageTag extends org.apache.struts.taglib.html.ImageTag
31 {
32 /***
33 * Allow a relative img src path to be used within a PortletRequest context.
34 * <p>
35 * Temporarily modifies the {@link #src} attribute value (if defined and if within the
36 * context of a {@link PortletServlet#isPortletRequest(ServletRequest) PortletRequest}).<br/>
37 * A relative src path is changed to a context relative path using the current
38 * request uri.</p>
39 * @return {@link #EVAL_PAGE}
40 */
41 public int doEndTag() throws JspException
42 {
43 String src = getSrc();
44 if ( PortletServlet.isPortletRequest(pageContext.getRequest()) && src != null )
45 {
46 try
47 {
48 setSrc(TagsSupport.getContextRelativeURL(pageContext,src,true));
49 super.doEndTag();
50 }
51 finally
52 {
53 setSrc(src);
54 }
55 }
56 else
57 {
58 super.doEndTag();
59 }
60 return (EVAL_PAGE);
61 }
62 }