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 Sergio Gonz??lez
023     */
024    public class SitesDirectoryTag extends IncludeTag {
025    
026            public static final String SITES_CHILDREN = "children";
027    
028            public static final String SITES_PARENT_LEVEL = "parent-level";
029    
030            public static final String SITES_SIBLINGS = "siblings";
031    
032            public static final String SITES_TOP_LEVEL = "top-level";
033    
034            public void setDisplayStyle(String displayStyle) {
035                    _displayStyle = displayStyle;
036            }
037    
038            public void setSites(String sites) {
039                    _sites = sites;
040            }
041    
042            @Override
043            protected void cleanUp() {
044                    _displayStyle = "descriptive";
045                    _sites = SITES_TOP_LEVEL;
046            }
047    
048            @Override
049            protected String getPage() {
050                    return _PAGE;
051            }
052    
053            @Override
054            protected void setAttributes(HttpServletRequest request) {
055                    request.setAttribute(
056                            "liferay-ui:sites-directory:displayStyle", _displayStyle);
057                    request.setAttribute(
058                            "liferay-ui:sites-directory:sites", String.valueOf(_sites));
059            }
060    
061            private static final String _PAGE =
062                    "/html/taglib/ui/sites_directory/page.jsp";
063    
064            private String _displayStyle = "descriptive";
065            private String _sites = SITES_TOP_LEVEL;
066    
067    }