001    /**
002     * Copyright (c) 2000-present 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.taglib.util.IncludeTag;
018    
019    import javax.servlet.http.HttpServletRequest;
020    
021    /**
022     * @author Carlos Lancha
023     */
024    public class AlertTag extends IncludeTag {
025    
026            @Override
027            public int doStartTag() {
028                    setAttributeNamespace(_ATTRIBUTE_NAMESPACE);
029    
030                    return EVAL_BODY_INCLUDE;
031            }
032    
033            public void setAnimationTime(Integer animationTime) {
034                    _animationTime = animationTime;
035    
036                    setScopedAttribute("animationTime", animationTime);
037            }
038    
039            public void setCloseable(boolean closeable) {
040                    _closeable = closeable;
041    
042                    setScopedAttribute("closeable", closeable);
043            }
044    
045            public void setCssClass(String cssClass) {
046                    _cssClass = cssClass;
047    
048                    setScopedAttribute("cssClass", cssClass);
049            }
050    
051            public void setDestroyOnHide(boolean destroyOnHide) {
052                    _destroyOnHide = destroyOnHide;
053    
054                    setScopedAttribute("destroyOnHide", destroyOnHide);
055            }
056    
057            public void setIcon(String icon) {
058                    _icon = icon;
059    
060                    setScopedAttribute("icon", icon);
061            }
062    
063            public void setMessage(String message) {
064                    _message = message;
065    
066                    setScopedAttribute("message", message);
067            }
068    
069            public void setTargetContainer(String targetContainer) {
070                    _targetContainer = targetContainer;
071    
072                    setScopedAttribute("targetContainer", targetContainer);
073            }
074    
075            public void setTimeout(Integer timeout) {
076                    _timeout = timeout;
077    
078                    setScopedAttribute("timeout", timeout);
079            }
080    
081            public void setTitle(String title) {
082                    _title = title;
083    
084                    setScopedAttribute("title", title);
085            }
086    
087            public void setType(String type) {
088                    _type = type;
089    
090                    setScopedAttribute("type", type);
091            }
092    
093            @Override
094            protected void cleanUp() {
095                    super.cleanUp();
096    
097                    _animationTime = 500;
098                    _closeable = true;
099                    _icon = "info-circle";
100                    _message = null;
101                    _cssClass = null;
102                    _destroyOnHide = false;
103                    _targetContainer = null;
104                    _timeout = -1;
105                    _title = null;
106                    _type = "info";
107            }
108    
109            @Override
110            protected String getPage() {
111                    return _PAGE;
112            }
113    
114            @Override
115            protected void setAttributes(HttpServletRequest request) {
116                    setNamespacedAttribute(request, "animationTime", _animationTime);
117                    setNamespacedAttribute(request, "closeable", _closeable);
118                    setNamespacedAttribute(request, "icon", _icon);
119                    setNamespacedAttribute(request, "message", _message);
120                    setNamespacedAttribute(request, "cssClass", _cssClass);
121                    setNamespacedAttribute(request, "destroyOnHide", _destroyOnHide);
122                    setNamespacedAttribute(request, "targetContainer", _targetContainer);
123                    setNamespacedAttribute(request, "timeout", _timeout);
124                    setNamespacedAttribute(request, "title", _title);
125                    setNamespacedAttribute(request, "type", _type);
126            }
127    
128            private static final String _ATTRIBUTE_NAMESPACE = "liferay-ui:alert:";
129    
130            private static final String _PAGE = "/html/taglib/ui/alert/page.jsp";
131    
132            private Integer _animationTime = 500;
133            private boolean _closeable = true;
134            private String _cssClass;
135            private boolean _destroyOnHide;
136            private String _icon = "info-circle";
137            private String _message;
138            private String _targetContainer;
139            private Integer _timeout = -1;
140            private String _title;
141            private String _type = "info";
142    
143    }