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.portal.kernel.servlet.taglib.ui;
016    
017    import com.liferay.portal.model.User;
018    
019    import java.io.IOException;
020    
021    import java.util.Locale;
022    
023    import javax.servlet.http.HttpServletRequest;
024    import javax.servlet.http.HttpServletResponse;
025    
026    /**
027     * Provides an interface defining entries that will be used by a specific
028     * <code>liferay-ui:form-navigator</code> tag instance to render a new section.
029     * Form navigator entries are included within form navigator categories, defined
030     * by {@link FormNavigatorCategory} implementations.
031     *
032     * <p>
033     * Implementations must be registered in the OSGi Registry. The order of the
034     * form navigator entries inside a category is determined by the service
035     * ranking.
036     * </p>
037     *
038     * @author Sergio Gonz??lez
039     */
040    public interface FormNavigatorEntry<T> {
041    
042            /**
043             * Returns the category key where the form navigator entry will be included.
044             *
045             * @return the category key where the form navigator entry will be included
046             */
047            public String getCategoryKey();
048    
049            /**
050             * Returns the form navigator ID where the form navigator entry will be
051             * included. This ID must match the ID attribute of the
052             * <code>liferay-ui:form-navigator</code> tag, where this form navigator
053             * entry is to be included.
054             *
055             * @return the form navigator ID where the form navigator entry will be
056             *         included
057             */
058            public String getFormNavigatorId();
059    
060            /**
061             * Returns the key for the form navigator entry. This key needs to be unique
062             * in the scope of a category key and form navigator ID.
063             *
064             * @return the key of the form navigator entry
065             */
066            public String getKey();
067    
068            /**
069             * Returns the label that will be displayed in the user interface when the
070             * form navigator entry is included in the form navigator.
071             *
072             * @param  locale the locale that the label should be retrieved for
073             * @return the label of the form navigator entry
074             */
075            public String getLabel(Locale locale);
076    
077            /**
078             * Renders the HTML that needs to be displayed when the form navigator entry
079             * is displayed.
080             *
081             * @param  request the request with which the form navigator entry is
082             *         rendered
083             * @param  response the response with which the form navigator entry is
084             *         rendered
085             * @throws IOException if an IO exception occurs
086             */
087            public void include(
088                            HttpServletRequest request, HttpServletResponse response)
089                    throws IOException;
090    
091            /**
092             * Returns <code>true</code> if the form navigator entry should be
093             * displayed.
094             *
095             * @param  user the user viewing the form navigator entry
096             * @param  formModelBean the bean edited by the form navigator, or
097             *         <code>null</code>
098             * @return <code>true</code> if the form navigator entry should be
099             *         displayed; <code>false</code> otherwise
100             */
101            public boolean isVisible(User user, T formModelBean);
102    
103    }