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.Validator;
018    import com.liferay.taglib.util.IncludeTag;
019    
020    import javax.servlet.http.HttpServletRequest;
021    
022    /**
023     * @author Julio Camarero
024     */
025    public class InputLocalizedTag extends IncludeTag {
026    
027            public void setCssClass(String cssClass) {
028                    _cssClass = cssClass;
029            }
030    
031            public void setDefaultLanguageId(String defaultLanguageId) {
032                    _defaultLanguageId = defaultLanguageId;
033            }
034    
035            public void setDisabled(boolean disabled) {
036                    _disabled = disabled;
037            }
038    
039            public void setFormName(String formName) {
040                    _formName = formName;
041            }
042    
043            public void setLanguageId(String languageId) {
044                    _languageId = languageId;
045            }
046    
047            public void setName(String name) {
048                    _name = name;
049            }
050    
051            public void setType(String type) {
052                    _type = type;
053            }
054    
055            public void setXml(String xml) {
056                    _xml = xml;
057            }
058    
059            @Override
060            protected void cleanUp() {
061                    _cssClass = null;
062                    _disabled = false;
063                    _formName = null;
064                    _languageId = null;
065                    _name = null;
066                    _type = "input";
067                    _xml = null;
068            }
069    
070            @Override
071            protected String getPage() {
072                    return _PAGE;
073            }
074    
075            @Override
076            protected void setAttributes(HttpServletRequest request) {
077                    String formName = _formName;
078    
079                    if (Validator.isNull(formName)) {
080                            formName = "fm";
081                    }
082    
083                    request.setAttribute("liferay-ui:input-localized:cssClass", _cssClass);
084                    request.setAttribute(
085                            "liferay-ui:input-localized:defaultLanguageId", _defaultLanguageId);
086                    request.setAttribute(
087                            "liferay-ui:input-localized:disabled", String.valueOf(_disabled));
088                    request.setAttribute(
089                            "liferay-ui:input-localized:dynamicAttributes",
090                            getDynamicAttributes());
091                    request.setAttribute("liferay-ui:input-localized:formName", formName);
092                    request.setAttribute(
093                            "liferay-ui:input-localized:languageId", _languageId);
094                    request.setAttribute("liferay-ui:input-localized:name", _name);
095                    request.setAttribute("liferay-ui:input-localized:type", _type);
096                    request.setAttribute("liferay-ui:input-localized:xml", _xml);
097            }
098    
099            private static final String _PAGE =
100                    "/html/taglib/ui/input_localized/page.jsp";
101    
102            private String _cssClass;
103            private String _defaultLanguageId;
104            private boolean _disabled;
105            private String _formName;
106            private String _languageId;
107            private String _name;
108            private String _type = "input";
109            private String _xml;
110    
111    }