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 java.util.List;
020    
021    import javax.servlet.http.HttpServletRequest;
022    
023    /**
024     * @author Juan Fern??ndez
025     */
026    public class DDMTemplateSelectorTag extends IncludeTag {
027    
028            public void setClassNameId(long classNameId) {
029                    _classNameId = classNameId;
030            }
031    
032            public void setDisplayStyle(String displayStyle) {
033                    _displayStyle = displayStyle;
034            }
035    
036            public void setDisplayStyleGroupId(long displayStyleGroupId) {
037                    _displayStyleGroupId = displayStyleGroupId;
038            }
039    
040            public void setDisplayStyles(List<String> displayStyles) {
041                    _displayStyles = displayStyles;
042            }
043    
044            public void setIcon(String icon) {
045                    _icon = icon;
046            }
047    
048            public void setLabel(String label) {
049                    _label = label;
050            }
051    
052            public void setRefreshURL(String refreshURL) {
053                    _refreshURL = refreshURL;
054            }
055    
056            public void setShowEmptyOption(boolean showEmptyOption) {
057                    _showEmptyOption = showEmptyOption;
058            }
059    
060            @Override
061            protected void cleanUp() {
062                    _classNameId = 0;
063                    _displayStyle = null;
064                    _displayStyleGroupId = 0;
065                    _displayStyles = null;
066                    _icon = null;
067                    _label = "display-template";
068                    _refreshURL = null;
069                    _showEmptyOption = false;
070            }
071    
072            @Override
073            protected String getPage() {
074                    return _PAGE;
075            }
076    
077            @Override
078            protected void setAttributes(HttpServletRequest request) {
079                    request.setAttribute(
080                            "liferay-ui:ddm-template-select:classNameId",
081                            String.valueOf(_classNameId));
082                    request.setAttribute(
083                            "liferay-ui:ddm-template-select:displayStyle", _displayStyle);
084                    request.setAttribute(
085                            "liferay-ui:ddm-template-select:displayStyleGroupId",
086                            String.valueOf(_displayStyleGroupId));
087                    request.setAttribute(
088                            "liferay-ui:ddm-template-select:displayStyles", _displayStyles);
089                    request.setAttribute("liferay-ui:ddm-template-select:icon", _icon);
090                    request.setAttribute("liferay-ui:ddm-template-select:label", _label);
091                    request.setAttribute(
092                            "liferay-ui:ddm-template-select:refreshURL", _refreshURL);
093                    request.setAttribute(
094                            "liferay-ui:ddm-template-select:showEmptyOption",
095                            String.valueOf(_showEmptyOption));
096            }
097    
098            private static final String _PAGE =
099                    "/html/taglib/ui/ddm_template_selector/page.jsp";
100    
101            private long _classNameId;
102            private String _displayStyle;
103            private long _displayStyleGroupId;
104            private List<String> _displayStyles;
105            private String _icon;
106            private String _label = "display-template";
107            private String _refreshURL;
108            private boolean _showEmptyOption;
109    
110    }