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(
035                            request, "responsiveButtons", _responsiveButtonsSB.toString());
036    
037                    return super.doEndTag();
038            }
039    
040            public StringBundler getResponsiveButtonsSB() {
041                    return _responsiveButtonsSB;
042            }
043    
044            @Override
045            protected void cleanUp() {
046                    super.cleanUp();
047    
048                    _responsiveButtonsSB.setIndex(0);
049            }
050    
051            @Override
052            protected String getPage() {
053                    String markupView = getMarkupView();
054    
055                    if (Validator.isNotNull(markupView)) {
056                            return "/html/taglib/aui/nav_bar/" + markupView + "/page.jsp";
057                    }
058    
059                    return "/html/taglib/aui/nav_bar/page.jsp";
060            }
061    
062            @Override
063            protected int processStartTag() throws Exception {
064                    return EVAL_BODY_BUFFERED;
065            }
066    
067            private final StringBundler _responsiveButtonsSB = new StringBundler();
068    
069    }