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 setPortletURL(PortletURL portletURL) {
042                    _portletURL = portletURL.toString();
043            }
044    
045            public void setPortletURL(String portletURL) {
046                    _portletURL = portletURL;
047            }
048    
049            public void setTotalEntries(int totalEntries) {
050                    _totalEntries = totalEntries;
051            }
052    
053            @Override
054            protected void cleanUp() {
055                    super.cleanUp();
056    
057                    _confirmMessage = _CONFIRM_MESSAGE;
058                    _emptyMessage = _EMPTY_MESSAGE;
059                    _portletURL = null;
060                    _totalEntries = 0;
061            }
062    
063            @Override
064            protected String getPage() {
065                    return _PAGE;
066            }
067    
068            @Override
069            protected boolean isCleanUpSetAttributes() {
070                    return _CLEAN_UP_SET_ATTRIBUTES;
071            }
072    
073            @Override
074            protected void setAttributes(HttpServletRequest request) {
075                    request.setAttribute(
076                            "liferay-ui:trash-empty:confirmMessage", _confirmMessage);
077                    request.setAttribute(
078                            "liferay-ui:trash-empty:emptyMessage", _emptyMessage);
079                    request.setAttribute("liferay-ui:trash-empty:portletURL", _portletURL);
080                    request.setAttribute(
081                            "liferay-ui:trash-empty:totalEntries", _totalEntries);
082            }
083    
084            private static final boolean _CLEAN_UP_SET_ATTRIBUTES = true;
085    
086            private static final String _CONFIRM_MESSAGE =
087                    "are-you-sure-you-want-to-empty-the-recycle-bin";
088    
089            private static final String _EMPTY_MESSAGE = "empty-the-recycle-bin";
090    
091            private static final String _PAGE = "/html/taglib/ui/trash_empty/page.jsp";
092    
093            private String _confirmMessage = _CONFIRM_MESSAGE;
094            private String _emptyMessage = _EMPTY_MESSAGE;
095            private String _portletURL;
096            private int _totalEntries;
097    
098    }