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.aui;
016    
017    import com.liferay.portal.kernel.util.StringBundler;
018    import com.liferay.portal.kernel.util.Validator;
019    import com.liferay.taglib.aui.base.BaseNavBarTag;
020    
021    import javax.servlet.jsp.JspException;
022    import javax.servlet.jsp.tagext.BodyTag;
023    
024    /**
025     * @author Eduardo Lundgren
026     * @author Bruno Basto
027     * @author Nathan Cavanaugh
028     * @author Julio Camarero
029     */
030    public class NavBarTag extends BaseNavBarTag implements BodyTag {
031    
032            @Override
033            public int doEndTag() throws JspException {
034                    setNamespacedAttribute(request, "dataTarget", _dataTarget);
035                    setNamespacedAttribute(
036                            request, "responsiveButtons", _responsiveButtonsSB.toString());
037                    setNamespacedAttribute(request, "selectedItemName", _selectedItemName);
038    
039                    return super.doEndTag();
040            }
041    
042            public StringBundler getResponsiveButtonsSB() {
043                    return _responsiveButtonsSB;
044            }
045    
046            public void setDataTarget(String dataTarget) {
047                    _dataTarget = dataTarget;
048            }
049    
050            public void setSelectedItemName(String selectedItemName) {
051                    _selectedItemName = selectedItemName;
052            }
053    
054            @Override
055            protected void cleanUp() {
056                    super.cleanUp();
057    
058                    _dataTarget = null;
059                    _responsiveButtonsSB.setIndex(0);
060                    _selectedItemName = null;
061            }
062    
063            @Override
064            protected String getPage() {
065                    String markupView = getMarkupView();
066    
067                    if (Validator.isNotNull(markupView)) {
068                            return "/html/taglib/aui/nav_bar/" + markupView + "/page.jsp";
069                    }
070    
071                    return "/html/taglib/aui/nav_bar/page.jsp";
072            }
073    
074            @Override
075            protected int processStartTag() throws Exception {
076                    return EVAL_BODY_BUFFERED;
077            }
078    
079            private String _dataTarget;
080            private final StringBundler _responsiveButtonsSB = new StringBundler();
081            private String _selectedItemName;
082    
083    }