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.servlet.http.HttpServletRequest;
020    import javax.servlet.jsp.tagext.BodyTag;
021    
022    /**
023     * @author Brian Wing Shun Chan
024     */
025    public class SuccessTag extends IncludeTag implements BodyTag {
026    
027            @Override
028            public int doStartTag() {
029                    HttpServletRequest request =
030                            (HttpServletRequest)pageContext.getRequest();
031    
032                    request.setAttribute("liferay-ui:success:key", _key);
033                    request.setAttribute("liferay-ui:success:message", _message);
034                    request.setAttribute(
035                            "liferay-ui:success:translateMessage",
036                            String.valueOf(_translateMessage));
037    
038                    return EVAL_BODY_BUFFERED;
039            }
040    
041            public void setKey(String key) {
042                    _key = key;
043            }
044    
045            public void setMessage(String message) {
046                    _message = message;
047            }
048    
049            public void setTranslateMessage(boolean translateMessage) {
050                    _translateMessage = translateMessage;
051            }
052    
053            @Override
054            protected String getPage() {
055                    return _PAGE;
056            }
057    
058            private static final String _PAGE = "/html/taglib/ui/success/page.jsp";
059    
060            private String _key;
061            private String _message;
062            private boolean _translateMessage = true;
063    
064    }