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.portal.kernel.servlet.taglib.ui.ToolbarItem;
018    import com.liferay.taglib.util.IncludeTag;
019    
020    import javax.servlet.http.HttpServletRequest;
021    
022    /**
023     * @author Iv??n Zaera
024     */
025    public class ToolbarItemTag extends IncludeTag {
026    
027            @Override
028            public int doStartTag() {
029                    return EVAL_BODY_INCLUDE;
030            }
031    
032            public void setToolbarItem(ToolbarItem toolbarItem) {
033                    _toolbarItem = toolbarItem;
034            }
035    
036            public void setVar(String var) {
037                    _var = var;
038            }
039    
040            @Override
041            protected void cleanUp() {
042                    _toolbarItem = null;
043                    _var = null;
044            }
045    
046            @Override
047            protected String getPage() {
048                    return _PAGE;
049            }
050    
051            @Override
052            protected boolean isCleanUpSetAttributes() {
053                    return _CLEAN_UP_SET_ATTRIBUTES;
054            }
055    
056            @Override
057            protected void setAttributes(HttpServletRequest request) {
058                    request.setAttribute(
059                            "liferay-ui:toolbar-item:toolbarItem", _toolbarItem);
060                    request.setAttribute("liferay-ui:toolbar-item:var", _var);
061            }
062    
063            private static final boolean _CLEAN_UP_SET_ATTRIBUTES = true;
064    
065            private static final String _PAGE = "/html/taglib/ui/toolbar_item/page.jsp";
066    
067            private ToolbarItem _toolbarItem;
068            private String _var;
069    
070    }