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 setLanguageId(String languageId) {
065                    _languageId = languageId;
066            }
067    
068            public void setModel(Class<?> model) {
069                    _model = model;
070            }
071    
072            public void setPlaceholder(String placeholder) {
073                    _placeholder = placeholder;
074            }
075    
076            @Override
077            protected void cleanUp() {
078                    _bean = null;
079                    _cssClass = null;
080                    _defaultLanguageId = null;
081                    _defaultValue = null;
082                    _disabled = false;
083                    _field = null;
084                    _fieldParam = null;
085                    _format = null;
086                    _formName = "fm";
087                    _languageId = null;
088                    _model = null;
089                    _placeholder = null;
090            }
091    
092            @Override
093            protected String getPage() {
094                    return _PAGE;
095            }
096    
097            @Override
098            protected void setAttributes(HttpServletRequest request) {
099                    request.setAttribute("liferay-ui:input-field:bean", _bean);
100                    request.setAttribute("liferay-ui:input-field:cssClass", _cssClass);
101                    request.setAttribute(
102                            "liferay-ui:input-field:defaultLanguageId", _defaultLanguageId);
103                    request.setAttribute(
104                            "liferay-ui:input-field:defaultValue", _defaultValue);
105                    request.setAttribute(
106                            "liferay-ui:input-field:disabled", String.valueOf(_disabled));
107                    request.setAttribute("liferay-ui:input-field:field", _field);
108                    request.setAttribute("liferay-ui:input-field:fieldParam", _fieldParam);
109                    request.setAttribute("liferay-ui:input-field:format", _format);
110                    request.setAttribute("liferay-ui:input-field:formName", _formName);
111                    request.setAttribute("liferay-ui:input-field:languageId", _languageId);
112                    request.setAttribute("liferay-ui:input-field:model", _model.getName());
113                    request.setAttribute(
114                            "liferay-ui:input-field:placeholder", _placeholder);
115            }
116    
117            private static final String _PAGE = "/html/taglib/ui/input_field/page.jsp";
118    
119            private Object _bean;
120            private String _cssClass;
121            private String _defaultLanguageId;
122            private Object _defaultValue;
123            private boolean _disabled;
124            private String _field;
125            private String _fieldParam;
126            private Format _format;
127            private String _formName = "fm";
128            private String _languageId;
129            private Class<?> _model;
130            private String _placeholder;
131    
132    }