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