001    /**
002     * Copyright (c) 2000-2012 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.taglib.util.IncludeTag;
018    
019    import javax.servlet.http.HttpServletRequest;
020    
021    /**
022     * @author Julio Camarero
023     */
024    public class FormNavigatorTag extends IncludeTag {
025    
026            @Override
027            public int doStartTag() {
028                    return EVAL_BODY_INCLUDE;
029            }
030    
031            public void setBackURL(String backURL) {
032                    _backURL = backURL;
033            }
034    
035            public void setCategoryNames(String[] categoryNames) {
036                    _categoryNames = categoryNames;
037            }
038    
039            public void setCategorySections(String[][] categorySections) {
040                    _categorySections = categorySections;
041            }
042    
043            public void setFormName(String formName) {
044                    _formName = formName;
045            }
046    
047            public void setHtmlBottom(String htmlBottom) {
048                    _htmlBottom = htmlBottom;
049            }
050    
051            public void setHtmlTop(String htmlTop) {
052                    _htmlTop = htmlTop;
053            }
054    
055            public void setJspPath(String jspPath) {
056                    _jspPath = jspPath;
057            }
058    
059            public void setShowButtons(boolean showButtons) {
060                    _showButtons = showButtons;
061            }
062    
063            @Override
064            protected void cleanUp() {
065                    _backURL = null;
066                    _categoryNames = null;
067                    _categorySections = null;
068                    _formName = "fm";
069                    _htmlBottom = null;
070                    _htmlTop = null;
071                    _jspPath = null;
072                    _showButtons = true;
073            }
074    
075            @Override
076            protected String getPage() {
077                    return _PAGE;
078            }
079    
080            @Override
081            protected void setAttributes(HttpServletRequest request) {
082                    request.setAttribute("liferay-ui:form-navigator:backURL", _backURL);
083                    request.setAttribute(
084                            "liferay-ui:form-navigator:categoryNames", _categoryNames);
085                    request.setAttribute(
086                            "liferay-ui:form-navigator:categorySections", _categorySections);
087                    request.setAttribute("liferay-ui:form-navigator:formName", _formName);
088                    request.setAttribute(
089                            "liferay-ui:form-navigator:htmlBottom", _htmlBottom);
090                    request.setAttribute("liferay-ui:form-navigator:htmlTop", _htmlTop);
091                    request.setAttribute("liferay-ui:form-navigator:jspPath", _jspPath);
092                    request.setAttribute(
093                            "liferay-ui:form-navigator:showButtons",
094                            String.valueOf(_showButtons));
095            }
096    
097            private static final String _PAGE =
098                    "/html/taglib/ui/form_navigator/page.jsp";
099    
100            private String _backURL;
101            private String[] _categoryNames;
102            private String[][] _categorySections;
103            private String _formName = "fm";
104            private String _htmlBottom;
105            private String _htmlTop;
106            private String _jspPath;
107            private boolean _showButtons = true;
108    
109    }