001    /**
002     * Copyright (c) 2000-2013 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.PortalIncludeUtil;
018    import com.liferay.portal.kernel.util.Validator;
019    
020    import javax.servlet.http.HttpServletRequest;
021    import javax.servlet.jsp.JspException;
022    import javax.servlet.jsp.tagext.TagSupport;
023    
024    /**
025     * @author Sergio González
026     */
027    public class AppViewNavigationTag extends TagSupport {
028    
029            @Override
030            public int doEndTag() throws JspException {
031                    try {
032                            PortalIncludeUtil.include(pageContext, getEndPage());
033    
034                            return EVAL_PAGE;
035                    }
036                    catch (Exception e) {
037                            throw new JspException(e);
038                    }
039            }
040    
041            @Override
042            public int doStartTag() throws JspException {
043                    try {
044                            HttpServletRequest request =
045                                    (HttpServletRequest)pageContext.getRequest();
046    
047                            request.setAttribute(
048                                    "liferay-ui:app-view-navigation:title", _title);
049    
050                            PortalIncludeUtil.include(pageContext, getStartPage());
051    
052                            return EVAL_BODY_INCLUDE;
053                    }
054                    catch (Exception e) {
055                            throw new JspException(e);
056                    }
057            }
058    
059            public void setEndPage(String endPage) {
060                    _endPage = endPage;
061            }
062    
063            public void setStartPage(String startPage) {
064                    _startPage = startPage;
065            }
066    
067            public void setTitle(String title) {
068                    _title = title;
069            }
070    
071            protected String getEndPage() {
072                    if (Validator.isNull(_endPage)) {
073                            return _END_PAGE;
074                    }
075                    else {
076                            return _endPage;
077                    }
078            }
079    
080            protected String getStartPage() {
081                    if (Validator.isNull(_startPage)) {
082                            return _START_PAGE;
083                    }
084                    else {
085                            return _startPage;
086                    }
087            }
088    
089            private static final String _END_PAGE =
090                    "/html/taglib/ui/app_view_navigation/end.jsp";
091    
092            private static final String _START_PAGE =
093                    "/html/taglib/ui/app_view_navigation/start.jsp";
094    
095            private String _endPage;
096            private String _startPage;
097            private String _title;
098    
099    }