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.language.LanguageUtil;
018    import com.liferay.portal.kernel.util.StringPool;
019    import com.liferay.taglib.aui.base.BaseNavItemTag;
020    import com.liferay.taglib.util.TagResourceBundleUtil;
021    
022    import java.util.ResourceBundle;
023    
024    import javax.servlet.http.HttpServletRequest;
025    import javax.servlet.jsp.JspException;
026    import javax.servlet.jsp.tagext.BodyTag;
027    
028    /**
029     * @author Eduardo Lundgren
030     * @author Bruno Basto
031     * @author Nathan Cavanaugh
032     * @author Julio Camarero
033     * @author Carlos Sierra Andr??s
034     */
035    public class NavItemTag extends BaseNavItemTag implements BodyTag {
036    
037            @Override
038            public int doStartTag() throws JspException {
039                    super.doStartTag();
040    
041                    return BodyTag.EVAL_BODY_BUFFERED;
042            }
043    
044            @Override
045            protected void setAttributes(HttpServletRequest request) {
046                    super.setAttributes(request);
047    
048                    if (!getUseDialog() && AUIUtil.isOpensNewWindow(getTarget())) {
049                            String title = getTitle();
050    
051                            if (title == null) {
052                                    title = StringPool.BLANK;
053                            }
054    
055                            ResourceBundle resourceBundle =
056                                    TagResourceBundleUtil.getResourceBundle(pageContext);
057    
058                            title = title.concat(
059                                    LanguageUtil.get(resourceBundle, "opens-new-window"));
060    
061                            setNamespacedAttribute(request, "title", String.valueOf(title));
062                    }
063            }
064    
065    }