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.portal.model.ModelHintsConstants;
019    import com.liferay.taglib.util.IncludeTag;
020    
021    import javax.servlet.http.HttpServletRequest;
022    
023    /**
024     * @author Julio Camarero
025     */
026    public class InputLocalizedTag extends IncludeTag {
027    
028            public void setAutoSize(boolean autoSize) {
029                    _autoSize = autoSize;
030            }
031    
032            public void setCssClass(String cssClass) {
033                    _cssClass = cssClass;
034            }
035    
036            public void setDefaultLanguageId(String defaultLanguageId) {
037                    _defaultLanguageId = defaultLanguageId;
038            }
039    
040            public void setDisabled(boolean disabled) {
041                    _disabled = disabled;
042            }
043    
044            public void setDisplayWidth(String displayWidth) {
045                    _displayWidth = displayWidth;
046            }
047    
048            public void setFormName(String formName) {
049                    _formName = formName;
050            }
051    
052            public void setId(String id) {
053                    _id = id;
054            }
055    
056            public void setIgnoreRequestValue(boolean ignoreRequestValue) {
057                    _ignoreRequestValue = ignoreRequestValue;
058            }
059    
060            public void setLanguageId(String languageId) {
061                    _languageId = languageId;
062            }
063    
064            public void setMaxLength(String maxLength) {
065                    _maxLength = maxLength;
066            }
067    
068            public void setName(String name) {
069                    _name = name;
070            }
071    
072            public void setType(String type) {
073                    _type = type;
074            }
075    
076            public void setXml(String xml) {
077                    _xml = xml;
078            }
079    
080            @Override
081            protected void cleanUp() {
082                    _autoSize = false;
083                    _cssClass = null;
084                    _disabled = false;
085                    _displayWidth = ModelHintsConstants.TEXT_DISPLAY_WIDTH;
086                    _formName = null;
087                    _id = null;
088                    _ignoreRequestValue = false;
089                    _languageId = null;
090                    _maxLength = null;
091                    _name = null;
092                    _type = "input";
093                    _xml = null;
094            }
095    
096            @Override
097            protected String getPage() {
098                    return _PAGE;
099            }
100    
101            @Override
102            protected void setAttributes(HttpServletRequest request) {
103                    String formName = _formName;
104    
105                    if (Validator.isNull(formName)) {
106                            formName = "fm";
107                    }
108    
109                    String id = _id;
110    
111                    if (Validator.isNull(id)) {
112                            id = _name;
113                    }
114    
115                    request.setAttribute(
116                            "liferay-ui:input-localized:autoSize", String.valueOf(_autoSize));
117                    request.setAttribute("liferay-ui:input-localized:cssClass", _cssClass);
118                    request.setAttribute(
119                            "liferay-ui:input-localized:defaultLanguageId", _defaultLanguageId);
120                    request.setAttribute(
121                            "liferay-ui:input-localized:displayWidth", _displayWidth);
122                    request.setAttribute(
123                            "liferay-ui:input-localized:disabled", String.valueOf(_disabled));
124                    request.setAttribute(
125                            "liferay-ui:input-localized:dynamicAttributes",
126                            getDynamicAttributes());
127                    request.setAttribute("liferay-ui:input-localized:formName", formName);
128                    request.setAttribute("liferay-ui:input-localized:id", id);
129                    request.setAttribute(
130                            "liferay-ui:input-localized:ignoreRequestValue",
131                            String.valueOf(_ignoreRequestValue));
132                    request.setAttribute(
133                            "liferay-ui:input-localized:languageId", _languageId);
134                    request.setAttribute(
135                            "liferay-ui:input-localized:maxLength", _maxLength);
136                    request.setAttribute("liferay-ui:input-localized:name", _name);
137                    request.setAttribute("liferay-ui:input-localized:type", _type);
138                    request.setAttribute("liferay-ui:input-localized:xml", _xml);
139            }
140    
141            private static final String _PAGE =
142                    "/html/taglib/ui/input_localized/page.jsp";
143    
144            private boolean _autoSize;
145            private String _cssClass;
146            private String _defaultLanguageId;
147            private boolean _disabled;
148            private String _displayWidth = ModelHintsConstants.TEXT_DISPLAY_WIDTH;
149            private String _formName;
150            private String _id;
151            private boolean _ignoreRequestValue;
152            private String _languageId;
153            private String _maxLength;
154            private String _name;
155            private String _type = "input";
156            private String _xml;
157    
158    }