1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * This library is free software; you can redistribute it and/or modify it under
5    * the terms of the GNU Lesser General Public License as published by the Free
6    * Software Foundation; either version 2.1 of the License, or (at your option)
7    * any later version.
8    *
9    * This library is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   * details.
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:lang");
42              request.removeAttribute("liferay-ui:icon:message");
43              request.removeAttribute("liferay-ui:icon:method");
44              request.removeAttribute("liferay-ui:icon:src");
45              request.removeAttribute("liferay-ui:icon:srcHover");
46              request.removeAttribute("liferay-ui:icon:target");
47              request.removeAttribute("liferay-ui:icon:toolTip");
48              request.removeAttribute("liferay-ui:icon:url");
49  
50              return value;
51          }
52          catch (Exception e) {
53              throw new JspException(e);
54          }
55          finally {
56              if (!ServerDetector.isResin()) {
57                  _cssClass = null;
58                  _image = null;
59                  _imageHover = null;
60                  _label = false;
61                  _lang = null;
62                  _message = null;
63                  _method = null;
64                  _src = null;
65                  _srcHover = null;
66                  _target = null;
67                  _toolTip = false;
68                  _url = null;
69              }
70          }
71      }
72  
73      public int doStartTag() {
74          HttpServletRequest request =
75              (HttpServletRequest)pageContext.getRequest();
76  
77          request.setAttribute("liferay-ui:icon:cssClass", _cssClass);
78          request.setAttribute("liferay-ui:icon:image", _image);
79          request.setAttribute("liferay-ui:icon:imageHover", _imageHover);
80          request.setAttribute("liferay-ui:icon:label", String.valueOf(_label));
81          request.setAttribute("liferay-ui:icon:lang", _lang);
82          request.setAttribute("liferay-ui:icon:message", _message);
83          request.setAttribute("liferay-ui:icon:method", _method);
84          request.setAttribute("liferay-ui:icon:src", _src);
85          request.setAttribute("liferay-ui:icon:srcHover", _srcHover);
86          request.setAttribute("liferay-ui:icon:target", _target);
87          request.setAttribute(
88              "liferay-ui:icon:toolTip", String.valueOf(_toolTip));
89          request.setAttribute("liferay-ui:icon:url", _url);
90  
91          return EVAL_BODY_BUFFERED;
92      }
93  
94      public void setCssClass(String cssClass) {
95          _cssClass = cssClass;
96      }
97  
98      public void setImage(String image) {
99          _image = image;
100     }
101 
102     public void setImageHover(String imageHover) {
103         _imageHover = imageHover;
104     }
105 
106     public void setLabel(boolean label) {
107         _label = label;
108     }
109 
110     public void setLang(String lang) {
111         _lang = lang;
112     }
113 
114     public void setMessage(String message) {
115         _message = message;
116     }
117 
118     public void setMethod(String method) {
119         _method = method;
120     }
121 
122     public void setSrc(String src) {
123         _src = src;
124     }
125 
126     public void setSrcHover(String srcHover) {
127         _srcHover = srcHover;
128     }
129 
130     public void setTarget(String target) {
131         _target = target;
132     }
133 
134     public void setToolTip(boolean toolTip) {
135         _toolTip = toolTip;
136     }
137 
138     public void setUrl(String url) {
139         _url = url;
140     }
141 
142     protected String getDefaultPage() {
143         return _PAGE;
144     }
145 
146     private static final String _PAGE = "/html/taglib/ui/icon/page.jsp";
147 
148     private String _cssClass;
149     private String _image;
150     private String _imageHover;
151     private boolean _label;
152     private String _lang;
153     private String _message;
154     private String _method;
155     private String _src;
156     private String _srcHover;
157     private String _target = "_self";
158     private boolean _toolTip = true;
159     private String _url;
160 
161 }