001    /**
002     * Copyright (c) 2000-2011 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
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(
098                            "liferay-ui:asset-tags-selector:id", id);
099            }
100    
101            private static final String _PAGE =
102                    "/html/taglib/ui/asset_tags_selector/page.jsp";
103    
104            private String _className;
105            private long _classPK;
106            private String _contentCallback;
107            private String _curTags;
108            private boolean _focus;
109            private String _hiddenInput = "assetTagNames";
110            private String _id;
111    
112    }