001    /**
002     * Copyright (c) 2000-2012 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.portal.kernel.util.StringPool;
018    import com.liferay.portal.kernel.util.Validator;
019    import com.liferay.portal.util.PortalUtil;
020    import com.liferay.taglib.util.IncludeTag;
021    
022    import javax.servlet.http.HttpServletRequest;
023    
024    /**
025     * @author Brian Wing Shun Chan
026     * @author Jorge Ferrer
027     */
028    public class AssetTagsSelectorTag extends IncludeTag {
029    
030            public void setClassName(String className) {
031                    _className = className;
032            }
033    
034            public void setClassPK(long classPK) {
035                    _classPK = classPK;
036            }
037    
038            public void setContentCallback(String contentCallback) {
039                    _contentCallback = contentCallback;
040            }
041    
042            public void setCurTags(String curTags) {
043                    _curTags = curTags;
044            }
045    
046            public void setFocus(boolean focus) {
047                    _focus = focus;
048            }
049    
050            public void setHiddenInput(String hiddenInput) {
051                    _hiddenInput = hiddenInput;
052            }
053    
054            public void setId(String id) {
055                    _id = id;
056            }
057    
058            @Override
059            protected void cleanUp() {
060                    _className = null;
061                    _classPK = 0;
062                    _contentCallback = null;
063                    _curTags = null;
064                    _focus = false;
065                    _hiddenInput = "assetTagNames";
066                    _id = null;
067            }
068    
069            @Override
070            protected String getPage() {
071                    return _PAGE;
072            }
073    
074            @Override
075            protected void setAttributes(HttpServletRequest request) {
076                    String id = _id;
077    
078                    if (Validator.isNull(id)) {
079                            id = PortalUtil.generateRandomKey(
080                                    request,
081                                    "taglib_ui_asset_tags_selector_page") + StringPool.UNDERLINE;
082                    }
083    
084                    request.setAttribute(
085                            "liferay-ui:asset-tags-selector:className", _className);
086                    request.setAttribute(
087                            "liferay-ui:asset-tags-selector:classPK", String.valueOf(_classPK));
088                    request.setAttribute(
089                            "liferay-ui:asset-tags-selector:contentCallback",
090                            String.valueOf(_contentCallback));
091                    request.setAttribute(
092                            "liferay-ui:asset-tags-selector:curTags", _curTags);
093                    request.setAttribute(
094                            "liferay-ui:asset-tags-selector:focus", String.valueOf(_focus));
095                    request.setAttribute(
096                            "liferay-ui:asset-tags-selector:hiddenInput", _hiddenInput);
097                    request.setAttribute("liferay-ui:asset-tags-selector:id", id);
098            }
099    
100            private static final String _PAGE =
101                    "/html/taglib/ui/asset_tags_selector/page.jsp";
102    
103            private String _className;
104            private long _classPK;
105            private String _contentCallback;
106            private String _curTags;
107            private boolean _focus;
108            private String _hiddenInput = "assetTagNames";
109            private String _id;
110    
111    }