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.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 setId(String id) {
044                    _id = id;
045            }
046    
047            public void setIgnoreRequestValue(boolean ignoreRequestValue) {
048                    _ignoreRequestValue = ignoreRequestValue;
049            }
050    
051            public void setLanguageId(String languageId) {
052                    _languageId = languageId;
053            }
054    
055            public void setMaxLength(String maxLength) {
056                    _maxLength = maxLength;
057            }
058    
059            public void setName(String name) {
060                    _name = name;
061            }
062    
063            public void setType(String type) {
064                    _type = type;
065            }
066    
067            public void setXml(String xml) {
068                    _xml = xml;
069            }
070    
071            @Override
072            protected void cleanUp() {
073                    _cssClass = null;
074                    _disabled = false;
075                    _formName = null;
076                    _id = null;
077                    _ignoreRequestValue = false;
078                    _languageId = null;
079                    _maxLength = null;
080                    _name = null;
081                    _type = "input";
082                    _xml = null;
083            }
084    
085            @Override
086            protected String getPage() {
087                    return _PAGE;
088            }
089    
090            @Override
091            protected void setAttributes(HttpServletRequest request) {
092                    String formName = _formName;
093    
094                    if (Validator.isNull(formName)) {
095                            formName = "fm";
096                    }
097    
098                    String id = _id;
099    
100                    if (Validator.isNull(id)) {
101                            id = _name;
102                    }
103    
104                    request.setAttribute("liferay-ui:input-localized:cssClass", _cssClass);
105                    request.setAttribute(
106                            "liferay-ui:input-localized:defaultLanguageId", _defaultLanguageId);
107                    request.setAttribute(
108                            "liferay-ui:input-localized:disabled", String.valueOf(_disabled));
109                    request.setAttribute(
110                            "liferay-ui:input-localized:dynamicAttributes",
111                            getDynamicAttributes());
112                    request.setAttribute("liferay-ui:input-localized:formName", formName);
113                    request.setAttribute("liferay-ui:input-localized:id", id);
114                    request.setAttribute(
115                            "liferay-ui:input-localized:ignoreRequestValue",
116                            String.valueOf(_ignoreRequestValue));
117                    request.setAttribute(
118                            "liferay-ui:input-localized:languageId", _languageId);
119                    request.setAttribute(
120                            "liferay-ui:input-localized:maxLength", _maxLength);
121                    request.setAttribute("liferay-ui:input-localized:name", _name);
122                    request.setAttribute("liferay-ui:input-localized:type", _type);
123                    request.setAttribute("liferay-ui:input-localized:xml", _xml);
124            }
125    
126            private static final String _PAGE =
127                    "/html/taglib/ui/input_localized/page.jsp";
128    
129            private String _cssClass;
130            private String _defaultLanguageId;
131            private boolean _disabled;
132            private String _formName;
133            private String _id;
134            private boolean _ignoreRequestValue;
135            private String _languageId;
136            private String _maxLength;
137            private String _name;
138            private String _type = "input";
139            private String _xml;
140    
141    }