001    /**
002     * Copyright (c) 2000-2013 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 Julio Camarero
025     */
026    public class TrashUndoTag extends IncludeTag {
027    
028            @Override
029            public int doStartTag() {
030                    return EVAL_BODY_INCLUDE;
031            }
032    
033            public void setPortletURL(PortletURL portletURL) {
034                    _portletURL = portletURL.toString();
035            }
036    
037            public void setPortletURL(String portletURL) {
038                    _portletURL = portletURL;
039            }
040    
041            public void setRedirect(String redirect) {
042                    _redirect = redirect;
043            }
044    
045            @Override
046            protected void cleanUp() {
047                    _portletURL = null;
048                    _redirect = null;
049            }
050    
051            @Override
052            protected String getPage() {
053                    return _PAGE;
054            }
055    
056            @Override
057            protected boolean isCleanUpSetAttributes() {
058                    return _CLEAN_UP_SET_ATTRIBUTES;
059            }
060    
061            @Override
062            protected void setAttributes(HttpServletRequest request) {
063                    request.setAttribute("liferay-ui:trash-undo:portletURL", _portletURL);
064                    request.setAttribute("liferay-ui:trash-undo:redirect", _redirect);
065            }
066    
067            private static final boolean _CLEAN_UP_SET_ATTRIBUTES = true;
068    
069            private static final String _PAGE = "/html/taglib/ui/trash_undo/page.jsp";
070    
071            private String _portletURL;
072            private String _redirect;
073    
074    }