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.taglib.util.IncludeTag;
018    
019    import java.text.Format;
020    
021    import javax.servlet.http.HttpServletRequest;
022    
023    /**
024     * @author Brian Wing Shun Chan
025     */
026    public class InputFieldTag extends IncludeTag {
027    
028            public void setBean(Object bean) {
029                    _bean = bean;
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 setDefaultValue(Object defaultValue) {
041                    _defaultValue = defaultValue;
042            }
043    
044            public void setDisabled(boolean disabled) {
045                    _disabled = disabled;
046            }
047    
048            public void setField(String field) {
049                    _field = field;
050            }
051    
052            public void setFieldParam(String fieldParam) {
053                    _fieldParam = fieldParam;
054            }
055    
056            public void setFormat(Format format) {
057                    _format = format;
058            }
059    
060            public void setFormName(String formName) {
061                    _formName = formName;
062            }
063    
064            public void setIgnoreRequestValue(boolean ignoreRequestValue) {
065                    _ignoreRequestValue = ignoreRequestValue;
066            }
067    
068            public void setLanguageId(String languageId) {
069                    _languageId = languageId;
070            }
071    
072            public void setModel(Class<?> model) {
073                    _model = model;
074            }
075    
076            public void setPlaceholder(String placeholder) {
077                    _placeholder = placeholder;
078            }
079    
080            @Override
081            protected void cleanUp() {
082                    _bean = null;
083                    _cssClass = null;
084                    _defaultLanguageId = null;
085                    _defaultValue = null;
086                    _disabled = false;
087                    _field = null;
088                    _fieldParam = null;
089                    _format = null;
090                    _formName = "fm";
091                    _ignoreRequestValue = false;
092                    _languageId = null;
093                    _model = null;
094                    _placeholder = null;
095            }
096    
097            @Override
098            protected String getPage() {
099                    return _PAGE;
100            }
101    
102            @Override
103            protected void setAttributes(HttpServletRequest request) {
104                    request.setAttribute("liferay-ui:input-field:bean", _bean);
105                    request.setAttribute("liferay-ui:input-field:cssClass", _cssClass);
106                    request.setAttribute(
107                            "liferay-ui:input-field:defaultLanguageId", _defaultLanguageId);
108                    request.setAttribute(
109                            "liferay-ui:input-field:defaultValue", _defaultValue);
110                    request.setAttribute(
111                            "liferay-ui:input-field:disabled", String.valueOf(_disabled));
112                    request.setAttribute("liferay-ui:input-field:field", _field);
113                    request.setAttribute("liferay-ui:input-field:fieldParam", _fieldParam);
114                    request.setAttribute("liferay-ui:input-field:format", _format);
115                    request.setAttribute("liferay-ui:input-field:formName", _formName);
116                    request.setAttribute(
117                            "liferay-ui:input-field:ignoreRequestValue",
118                            String.valueOf(_ignoreRequestValue));
119                    request.setAttribute("liferay-ui:input-field:languageId", _languageId);
120                    request.setAttribute("liferay-ui:input-field:model", _model.getName());
121                    request.setAttribute(
122                            "liferay-ui:input-field:placeholder", _placeholder);
123            }
124    
125            private static final String _PAGE = "/html/taglib/ui/input_field/page.jsp";
126    
127            private Object _bean;
128            private String _cssClass;
129            private String _defaultLanguageId;
130            private Object _defaultValue;
131            private boolean _disabled;
132            private String _field;
133            private String _fieldParam;
134            private Format _format;
135            private String _formName = "fm";
136            private boolean _ignoreRequestValue;
137            private String _languageId;
138            private Class<?> _model;
139            private String _placeholder;
140    
141    }