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 setMessage(String message) {
058                    _message = message;
059    
060                    setScopedAttribute("message", message);
061            }
062    
063            public void setTargetContainer(String targetContainer) {
064                    _targetContainer = targetContainer;
065    
066                    setScopedAttribute("targetContainer", targetContainer);
067            }
068    
069            public void setTimeout(Integer timeout) {
070                    _timeout = timeout;
071    
072                    setScopedAttribute("timeout", timeout);
073            }
074    
075            public void setTitle(String title) {
076                    _title = title;
077    
078                    setScopedAttribute("title", title);
079            }
080    
081            public void setType(String type) {
082                    _type = type;
083    
084                    setScopedAttribute("type", type);
085            }
086    
087            @Override
088            protected void cleanUp() {
089                    super.cleanUp();
090    
091                    _animationTime = 500;
092                    _closeable = true;
093                    _message = null;
094                    _cssClass = null;
095                    _destroyOnHide = false;
096                    _targetContainer = null;
097                    _timeout = -1;
098                    _title = null;
099                    _type = "info";
100            }
101    
102            @Override
103            protected String getPage() {
104                    return _PAGE;
105            }
106    
107            @Override
108            protected void setAttributes(HttpServletRequest request) {
109                    setNamespacedAttribute(request, "animationTime", _animationTime);
110                    setNamespacedAttribute(request, "closeable", _closeable);
111                    setNamespacedAttribute(request, "message", _message);
112                    setNamespacedAttribute(request, "cssClass", _cssClass);
113                    setNamespacedAttribute(request, "destroyOnHide", _destroyOnHide);
114                    setNamespacedAttribute(request, "targetContainer", _targetContainer);
115                    setNamespacedAttribute(request, "timeout", _timeout);
116                    setNamespacedAttribute(request, "title", _title);
117                    setNamespacedAttribute(request, "type", _type);
118            }
119    
120            private static final String _ATTRIBUTE_NAMESPACE = "liferay-ui:alert:";
121    
122            private static final String _PAGE = "/html/taglib/ui/alert/page.jsp";
123    
124            private Integer _animationTime = 500;
125            private boolean _closeable = true;
126            private String _cssClass;
127            private boolean _destroyOnHide;
128            private String _message;
129            private String _targetContainer;
130            private Integer _timeout = -1;
131            private String _title;
132            private String _type = "info";
133    
134    }