001    /**
002     * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.taglib.ui;
016    
017    import com.liferay.portal.kernel.util.Validator;
018    import com.liferay.portal.util.PortalUtil;
019    import com.liferay.taglib.util.IncludeTag;
020    
021    import javax.servlet.http.HttpServletRequest;
022    
023    /**
024     * @author Brian Wing Shun Chan
025     */
026    public class IconTag extends IncludeTag {
027    
028            public void setCssClass(String cssClass) {
029                    _cssClass = cssClass;
030            }
031    
032            public void setId(String id) {
033                    _id = id;
034            }
035    
036            public void setImage(String image) {
037                    _image = image;
038            }
039    
040            public void setImageHover(String imageHover) {
041                    _imageHover = imageHover;
042            }
043    
044            public void setLabel(boolean label) {
045                    _label = label;
046            }
047    
048            public void setLang(String lang) {
049                    _lang = lang;
050            }
051    
052            public void setMessage(String message) {
053                    _message = message;
054            }
055    
056            public void setMethod(String method) {
057                    _method = method;
058            }
059    
060            public void setSrc(String src) {
061                    _src = src;
062            }
063    
064            public void setSrcHover(String srcHover) {
065                    _srcHover = srcHover;
066            }
067    
068            public void setTarget(String target) {
069                    _target = target;
070            }
071    
072            public void setToolTip(boolean toolTip) {
073                    _toolTip = toolTip;
074            }
075    
076            public void setUrl(String url) {
077                    _url = url;
078            }
079    
080            protected void cleanUp() {
081                    _cssClass = null;
082                    _id = null;
083                    _image = null;
084                    _imageHover = null;
085                    _label = false;
086                    _lang = null;
087                    _message = null;
088                    _method = null;
089                    _src = null;
090                    _srcHover = null;
091                    _target = null;
092                    _toolTip = false;
093                    _url = null;
094            }
095    
096            protected String getPage() {
097                    return _PAGE;
098            }
099    
100            protected boolean isCleanUpSetAttributes() {
101                    return _CLEAN_UP_SET_ATTRIBUTES;
102            }
103    
104            protected void setAttributes(HttpServletRequest request) {
105                    String id = _id;
106    
107                    if (Validator.isNull(id)) {
108                            id = PortalUtil.generateRandomKey(
109                                    request, IconTag.class.getName());
110                    }
111    
112                    request.setAttribute("liferay-ui:icon:cssClass", _cssClass);
113                    request.setAttribute("liferay-ui:icon:id", id);
114                    request.setAttribute("liferay-ui:icon:image", _image);
115                    request.setAttribute("liferay-ui:icon:imageHover", _imageHover);
116                    request.setAttribute("liferay-ui:icon:label", String.valueOf(_label));
117                    request.setAttribute("liferay-ui:icon:lang", _lang);
118                    request.setAttribute("liferay-ui:icon:message", _message);
119                    request.setAttribute("liferay-ui:icon:method", _method);
120                    request.setAttribute("liferay-ui:icon:src", _src);
121                    request.setAttribute("liferay-ui:icon:srcHover", _srcHover);
122                    request.setAttribute("liferay-ui:icon:target", _target);
123                    request.setAttribute(
124                            "liferay-ui:icon:toolTip", String.valueOf(_toolTip));
125                    request.setAttribute("liferay-ui:icon:url", _url);
126            }
127    
128            private static final boolean _CLEAN_UP_SET_ATTRIBUTES = true;
129    
130            private static final String _PAGE = "/html/taglib/ui/icon/page.jsp";
131    
132            private String _cssClass;
133            private String _id;
134            private String _image;
135            private String _imageHover;
136            private boolean _label;
137            private String _lang;
138            private String _message;
139            private String _method;
140            private String _src;
141            private String _srcHover;
142            private String _target = "_self";
143            private boolean _toolTip;
144            private String _url;
145    
146    }