001    /**
002     * Copyright (c) 2000-2012 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.portlet.PortletURL;
020    
021    import javax.servlet.http.HttpServletRequest;
022    
023    /**
024     * @author Sergio González
025     */
026    public class TrashEmptyTag extends IncludeTag {
027    
028            @Override
029            public int doStartTag() {
030                    return EVAL_BODY_INCLUDE;
031            }
032    
033            public void setConfirmMessage(String confirmMessage) {
034                    _confirmMessage = confirmMessage;
035            }
036    
037            public void setEmptyMessage(String emptyMessage) {
038                    _emptyMessage = emptyMessage;
039            }
040    
041            public void setInfoMessage(String infoMessage) {
042                    _infoMessage = infoMessage;
043            }
044    
045            public void setPortletURL(PortletURL portletURL) {
046                    _portletURL = portletURL.toString();
047            }
048    
049            public void setPortletURL(String portletURL) {
050                    _portletURL = portletURL;
051            }
052    
053            public void setTotalEntries(int totalEntries) {
054                    _totalEntries = totalEntries;
055            }
056    
057            @Override
058            protected void cleanUp() {
059                    _confirmMessage = _CONFIRM_MESSAGE;
060                    _emptyMessage = _EMPTY_MESSAGE;
061                    _infoMessage = _INFO_MESSAGE;
062                    _portletURL = null;
063                    _totalEntries = 0;
064            }
065    
066            @Override
067            protected String getPage() {
068                    return _PAGE;
069            }
070    
071            @Override
072            protected boolean isCleanUpSetAttributes() {
073                    return _CLEAN_UP_SET_ATTRIBUTES;
074            }
075    
076            @Override
077            protected void setAttributes(HttpServletRequest request) {
078                    request.setAttribute(
079                            "liferay-ui:trash-empty:confirmMessage", _confirmMessage);
080                    request.setAttribute(
081                            "liferay-ui:trash-empty:emptyMessage", _emptyMessage);
082                    request.setAttribute(
083                            "liferay-ui:trash-empty:infoMessage", _infoMessage);
084                    request.setAttribute("liferay-ui:trash-empty:portletURL", _portletURL);
085                    request.setAttribute(
086                            "liferay-ui:trash-empty:totalEntries", _totalEntries);
087            }
088    
089            private static final boolean _CLEAN_UP_SET_ATTRIBUTES = true;
090    
091            private static final String _CONFIRM_MESSAGE =
092                    "are-you-sure-you-want-to-empty-the-recycle-bin";
093    
094            private static final String _EMPTY_MESSAGE = "empty-the-recycle-bin";
095    
096            private static final String _INFO_MESSAGE =
097                    "entries-that-have-been-in-recycle-bin-for-more-than-x-days-will-be-" +
098                            "automatically-deleted";
099    
100            private static final String _PAGE = "/html/taglib/ui/trash_empty/page.jsp";
101    
102            private String _confirmMessage = _CONFIRM_MESSAGE;
103            private String _emptyMessage = _EMPTY_MESSAGE;
104            private String _infoMessage = _INFO_MESSAGE;
105            private String _portletURL;
106            private int _totalEntries;
107    
108    }