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.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 ImageSelectorTag extends IncludeTag {
025    
026            public void setDraggableImage(String draggableImage) {
027                    _draggableImage = draggableImage;
028            }
029    
030            public void setFileEntryId(long fileEntryId) {
031                    _fileEntryId = fileEntryId;
032            }
033    
034            public void setMaxFileSize(long maxFileSize) {
035                    _maxFileSize = maxFileSize;
036            }
037    
038            public void setParamName(String paramName) {
039                    _paramName = paramName;
040            }
041    
042            public void setUploadURL(String uploadURL) {
043                    _uploadURL = uploadURL;
044            }
045    
046            public void setValidExtensions(String validExtensions) {
047                    _validExtensions = validExtensions;
048            }
049    
050            @Override
051            protected void cleanUp() {
052                    _draggableImage = "none";
053                    _fileEntryId = 0;
054                    _maxFileSize = 0;
055                    _paramName = "imageSelectorFileEntryId";
056                    _uploadURL = null;
057                    _validExtensions = null;
058            }
059    
060            @Override
061            protected String getPage() {
062                    return _PAGE;
063            }
064    
065            @Override
066            protected void setAttributes(HttpServletRequest request) {
067                    request.setAttribute(
068                            "liferay-ui:image-selector:draggableImage", _draggableImage);
069                    request.setAttribute(
070                            "liferay-ui:image-selector:fileEntryId", _fileEntryId);
071                    request.setAttribute(
072                            "liferay-ui:image-selector:maxFileSize", _maxFileSize);
073                    request.setAttribute("liferay-ui:image-selector:paramName", _paramName);
074                    request.setAttribute("liferay-ui:image-selector:uploadURL", _uploadURL);
075                    request.setAttribute(
076                            "liferay-ui:image-selector:validExtensions", _validExtensions);
077            }
078    
079            private static final String _PAGE =
080                    "/html/taglib/ui/image_selector/page.jsp";
081    
082            private String _draggableImage = "none";
083            private long _fileEntryId;
084            private long _maxFileSize;
085            private String _paramName = "imageSelectorFileEntry";
086            private String _uploadURL;
087            private String _validExtensions;
088    
089    }