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.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 setDisplayStyle(String displayStyle) {
044                    _displayStyle = displayStyle;
045            }
046    
047            public void setFormName(String formName) {
048                    _formName = formName;
049            }
050    
051            public void setHtmlBottom(String htmlBottom) {
052                    _htmlBottom = htmlBottom;
053            }
054    
055            public void setHtmlTop(String htmlTop) {
056                    _htmlTop = htmlTop;
057            }
058    
059            public void setJspPath(String jspPath) {
060                    _jspPath = jspPath;
061            }
062    
063            public void setShowButtons(boolean showButtons) {
064                    _showButtons = showButtons;
065            }
066    
067            @Override
068            protected void cleanUp() {
069                    _backURL = null;
070                    _categoryNames = null;
071                    _categorySections = null;
072                    _displayStyle = "form";
073                    _formName = "fm";
074                    _htmlBottom = null;
075                    _htmlTop = null;
076                    _jspPath = null;
077                    _showButtons = true;
078            }
079    
080            @Override
081            protected String getPage() {
082                    return _PAGE;
083            }
084    
085            @Override
086            protected void setAttributes(HttpServletRequest request) {
087                    request.setAttribute("liferay-ui:form-navigator:backURL", _backURL);
088                    request.setAttribute(
089                            "liferay-ui:form-navigator:categoryNames", _categoryNames);
090                    request.setAttribute(
091                            "liferay-ui:form-navigator:categorySections", _categorySections);
092                    request.setAttribute(
093                            "liferay-ui:form-navigator:displayStyle", _displayStyle);
094                    request.setAttribute("liferay-ui:form-navigator:formName", _formName);
095                    request.setAttribute(
096                            "liferay-ui:form-navigator:htmlBottom", _htmlBottom);
097                    request.setAttribute("liferay-ui:form-navigator:htmlTop", _htmlTop);
098                    request.setAttribute("liferay-ui:form-navigator:jspPath", _jspPath);
099                    request.setAttribute(
100                            "liferay-ui:form-navigator:showButtons",
101                            String.valueOf(_showButtons));
102            }
103    
104            private static final String _PAGE =
105                    "/html/taglib/ui/form_navigator/page.jsp";
106    
107            private String _backURL;
108            private String[] _categoryNames;
109            private String[][] _categorySections;
110            private String _displayStyle = "form";
111            private String _formName = "fm";
112            private String _htmlBottom;
113            private String _htmlTop;
114            private String _jspPath;
115            private boolean _showButtons = true;
116    
117    }