1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   *
12   *
13   */
14  
15  package com.liferay.taglib.ui;
16  
17  import com.liferay.portal.kernel.util.ServerDetector;
18  import com.liferay.taglib.util.IncludeTag;
19  
20  import javax.servlet.http.HttpServletRequest;
21  import javax.servlet.jsp.JspException;
22  
23  /**
24   * <a href="IconTag.java.html"><b><i>View Source</i></b></a>
25   *
26   * @author Brian Wing Shun Chan
27   */
28  public class IconTag extends IncludeTag {
29  
30      public int doEndTag() throws JspException {
31          int value = super.doEndTag();
32  
33          try {
34              HttpServletRequest request =
35                  (HttpServletRequest)pageContext.getRequest();
36  
37              request.removeAttribute("liferay-ui:icon:cssClass");
38              request.removeAttribute("liferay-ui:icon:image");
39              request.removeAttribute("liferay-ui:icon:imageHover");
40              request.removeAttribute("liferay-ui:icon:label");
41              request.removeAttribute("liferay-ui:icon:message");
42              request.removeAttribute("liferay-ui:icon:method");
43              request.removeAttribute("liferay-ui:icon:src");
44              request.removeAttribute("liferay-ui:icon:srcHover");
45              request.removeAttribute("liferay-ui:icon:target");
46              request.removeAttribute("liferay-ui:icon:toolTip");
47              request.removeAttribute("liferay-ui:icon:url");
48  
49              return value;
50          }
51          catch (Exception e) {
52              throw new JspException(e);
53          }
54          finally {
55              if (!ServerDetector.isResin()) {
56                  _cssClass = null;
57                  _image = null;
58                  _imageHover = null;
59                  _label = false;
60                  _message = null;
61                  _method = null;
62                  _src = null;
63                  _srcHover = null;
64                  _target = null;
65                  _toolTip = false;
66                  _url = null;
67              }
68          }
69      }
70  
71      public int doStartTag() {
72          HttpServletRequest request =
73              (HttpServletRequest)pageContext.getRequest();
74  
75          request.setAttribute("liferay-ui:icon:cssClass", _cssClass);
76          request.setAttribute("liferay-ui:icon:image", _image);
77          request.setAttribute("liferay-ui:icon:imageHover", _imageHover);
78          request.setAttribute("liferay-ui:icon:label", String.valueOf(_label));
79          request.setAttribute("liferay-ui:icon:message", _message);
80          request.setAttribute("liferay-ui:icon:method", _method);
81          request.setAttribute("liferay-ui:icon:src", _src);
82          request.setAttribute("liferay-ui:icon:srcHover", _srcHover);
83          request.setAttribute("liferay-ui:icon:target", _target);
84          request.setAttribute(
85              "liferay-ui:icon:toolTip", String.valueOf(_toolTip));
86          request.setAttribute("liferay-ui:icon:url", _url);
87  
88          return EVAL_BODY_BUFFERED;
89      }
90  
91      public void setCssClass(String cssClass) {
92          _cssClass = cssClass;
93      }
94  
95      public void setImage(String image) {
96          _image = image;
97      }
98  
99      public void setImageHover(String imageHover) {
100         _imageHover = imageHover;
101     }
102 
103     public void setLabel(boolean label) {
104         _label = label;
105     }
106 
107     public void setMessage(String message) {
108         _message = message;
109     }
110 
111     public void setMethod(String method) {
112         _method = method;
113     }
114 
115     public void setSrc(String src) {
116         _src = src;
117     }
118 
119     public void setSrcHover(String srcHover) {
120         _srcHover = srcHover;
121     }
122 
123     public void setTarget(String target) {
124         _target = target;
125     }
126 
127     public void setToolTip(boolean toolTip) {
128         _toolTip = toolTip;
129     }
130 
131     public void setUrl(String url) {
132         _url = url;
133     }
134 
135     protected String getDefaultPage() {
136         return _PAGE;
137     }
138 
139     private static final String _PAGE = "/html/taglib/ui/icon/page.jsp";
140 
141     private String _cssClass;
142     private String _image;
143     private String _imageHover;
144     private boolean _label;
145     private String _message;
146     private String _method;
147     private String _src;
148     private String _srcHover;
149     private String _target = "_self";
150     private boolean _toolTip = true;
151     private String _url;
152 
153 }